Search code examples
bashgnu-parallel

&& in bash script using GNU "parallel"


I would like to run my bash my_script.sh using GNU parallel:

parallel < my_script.sh

where my_script.sh is:

command1 && command2
command3 
command4

Will command1 and command2 run in parallel or sequentially.
In case I am not clear:
command1
command2
command3
command4

or

command1 -> command2
command3
command4

?

Thank you!


Solution

  • && lets you do something based on whether the previous command completed successfully.


    It will run like this:

    command1 -> command2 (only if the exit status of "command1" is zero)
    command3
    command4