EN
Bash - run one command after second one when first one is succeed and done
6
points
In this short artlcle we would like to show how using Bash, run one command after second one only when first one succeed.
Quick solution:
first_command && second_command
Practical example
In this example, we present sleep and echo commands combining.
sleep 3 && echo "Sleep command done!"
Explaination:
-
sleepcommand sleeps command line for 3 seconds returning success status when is done (0status code), -
then echo
commandis run printingSleep command done!text in the command line.