How to run multiple commands at once in bash shell
In Category Bash Command Line Unix
All commands can be just appended using a semicolon (;) to make the bash to run all the commands one after the other as shown below.
[liz@techpulp ~]# make config; make; make release
The above command is equivalent to running three commands “make config”, “make” and “make release” one after the other. The only difference is that you don’t need wait for one command to finish to type in the next command.
However if you have a series of dependant commands that require the previous command to succeed to execute the next command, you can change the command as shown below.
[liz@techpulp ~]# make config && make && make release
In the above example, all commands are appended with “&&” operator which makes the bash to execute further commands if any command returns non-zero value. It means that if “make config” command is successful without any errors, then only bash proceeds with executing next command “make”. Otherwise it aborts further execution.
Typing too long commands is boring especially when they have to be repeated many a times. In such cases you can create a small shell script or use an alias to make your life easy.
Recent Comments