Linux 101 : Bash scripting - how to combine commands -



To execute a command "command1" in the background, so we still have access to the command prompt we use the below command:


To execute a sequence of commands we use the below:


To be able to execute a group of commands in the current shell, we use:


To be able to execute a group of commands in a new shell - subshell -, we use the below:


To use the output of "command1" as an argument for "command2", we use the below:


To use the "command2" output as argument for "command1", we use the below:


We could also use the below expression to have the output of "command2" work as an argument for "command1":


We could use the outcome of the arithmetic expression "exp" as an argument for the command "command1":


In the below expression, we have conditional execution of the commands.
The command "command2" is executed only if the "command1" succeeds, if it fails, then the command "command2" is not executed:


The below expression runs the command "command1". If "command1" succeeds, "command2" is not run.
If "command1" fails, then "command2" is executed:

Comments

Leave as a comment:

Archive