I have a sequence of small bash scripts that I need to run in a particular order.
I figured I could do this by creating a script that executes each script, one after the other, because most of the scripts take input from the output files of the previous.
However, when I try to execute the script, it tries to run each of the internal scripts at once, and returns a lot of no such file or directory
errors.
I have my script formatting like this.
#!/bin/bash
bash script1.sh
bash script2.sh
bash script3.sh
And I do not want to run script2.sh until script1.sh has finished executing. Is there a simple way to do this?
Edit: I forgot to mention that I have a few python scripts in the list as well. Not sure if that changes anything.
Best Answer
The correct solution for you depends on what you want:
&&
will only execute the second if the first exits successfully||
will only execute the second if the first doesn't exit successfullyIf you want the second command to be executed after the first no matter whether it exits successfully or not, you can use either
;
or& wait
: