我应该使用什么来等待 CSH 脚本中的命令完成?

发布于 2025-01-16 12:38:35 字数 411 浏览 2 评论 0原文

我知道如果 bash 脚本 (sh) 应该等到链接脚本执行完毕,我必须写一个分号 ;在线的末尾。

这看起来像这样:

rm -rf /home/uwbe/uems/runs/$1/wrf_out/bow_derecho_index_750hpa/$2/* ;

rm -rf /home/uwbe/uems/runs/$1/wrf_out/ref_dbmax_1000/$2/* ;

rm -rf /home/uwbe/uems/runs/$1/wrf_out/ref_dbmax_3000/$2/* ;

但是我如何在 CSH 中执行此操作(在 .csh 脚本、Tcsh shell 中)?我可以在末尾加一个分号,但脚本不会等待而是继续。

有人给我提示吗?

我尝试在 csh 中的这些行末尾加一个分号。

I know that if a bash script (sh) should wait until the linked script has finished executing, that I have to write a semicolon ; at the end of the line.

This then looks something like this:

rm -rf /home/uwbe/uems/runs/$1/wrf_out/bow_derecho_index_750hpa/$2/* ;

rm -rf /home/uwbe/uems/runs/$1/wrf_out/ref_dbmax_1000/$2/* ;

rm -rf /home/uwbe/uems/runs/$1/wrf_out/ref_dbmax_3000/$2/* ;

But how do I do this in the CSH (in a .csh script, Tcsh shell) ? I can put a semicolon at the end, but the script doesn't wait but continues.

Does anyone have a tip for me?

I have try to put also a semicolon at the end of these lines in csh.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你是暖光i 2025-01-23 12:38:37

在 Tcsh 中,链接运算符以这种方式起作用:

>> command_a && command_b  # command_b will be executed ONLY if command_a **succeeds**
>> command_a || command_b  # command_b will be executed ONLY if command_a **fails**
>> command_a ; command_b ; command_c  # both will executed by their order

因此您可以将所需的命令链接到一行。

另一种选择是使用要运行的命令创建一个文件,并在该文件上使用“source”命令。这将逐行执行命令(这通常发生在 .alias 文件上)-

>> source my_commands_file.txt

In Tcsh the chaining operator acts in this way:

>> command_a && command_b  # command_b will be executed ONLY if command_a **succeeds**
>> command_a || command_b  # command_b will be executed ONLY if command_a **fails**
>> command_a ; command_b ; command_c  # both will executed by their order

so you can chain the commands you need to one line.

Another option is to create a file with the commands you want to run , and use 'source' command on that file. This will execute the commands line by line (this usually happens on the .alias file) -

>> source my_commands_file.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文