'What should i use to wait until a Command is finished in CSH Script?

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.



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1