简体   繁体   English

如何在Linux上制作混合的bash / tcsh脚本?

[英]How can I make a hybrid bash/tcsh script on Linux?

I have one script which runs in Bash and and other which runs in tcsh. 我有一个在Bash中运行的脚本,另一个在tcsh中运行。

I need to run them both from the same script. 我需要从同一脚本运行它们。 How can I create a script that can run both bash and tcsh commands? 如何创建可以同时运行bash和tcsh命令的脚本?

Most shells have an argument which allow you to pass them a string to run as a command, for example, for bash you can run 大多数shell都有一个参数,允许您向其传递一个字符串以作为命令运行,例如,对于bash来说,您可以运行

bash -c "echo this is a bash script; echo lalalala"

to run that string as a script in bash, use this to run the needed shell embedded in the other. 要在bash中将该字符串作为脚本运行,请使用它运行嵌入到另一个脚本中的所需shell。 This will allow you to make a script in one shell which will invoke the other shell when the other program needs to be run. 这将允许您在一个shell中创建脚本,该脚本将在需要运行另一个程序时调用另一个shell。

If on the other hand they are both properly shebanged begin with #!tcsh or #!bash you can simply run both scripts from the same bash script using: 另一方面,如果它们都正确地以#!tcsh#!bash开头,则可以使用以下命令从同一bash脚本运行两个脚本:

/path/to/script1 &
/path/to/script2 &

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Linux上了解tcsh的TAB完成 - How can I hook into tcsh's TAB completion on Linux 如何在 tcsh 中获取源脚本的名称? - How can I get the name of the sourced script in tcsh? 如何以 tcsh 作为 shell 而不是 Bash 运行基于 linux 的 docker 容器? - How do I run the linux based docker container with tcsh as the shell instead of Bash? 如何使用 bash 脚本在 linux 中创建命令? - How do I make a command in linux using a bash script? 如何将linux bash脚本文件添加到terraform代码中? - How can i add linux bash script file into terraform code? 我怎样才能知道Linux脚本(ash(不是bash))正在“来源”运行? - How can I tell a Linux Script (ash, not bash) is running “sourced”? 如何通过bash查询Linux Mint中运行bash脚本的虚拟桌面数量? - How can I query the number of the virtual desktop on which the bash script is running in Linux Mint via bash? 如何使bash脚本不区分大小写? - How can I make a bash script case insensitive? 在BASH中,我需要根据perl脚本的输出来更改一些环境变量。 在tcsh中,我可以使用别名eval组合。 不能狂欢 - In BASH I need to change some environment variables based on output of a perl script. In tcsh I can use an alias eval combo. Can't in bash 简单的bash脚本,我怎样才能让它更短更好? - simple bash script, how can I make it shorter and better?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM