1. 程式人生 > >Linux Bash Scripting - Command Chaining & Command lists

Linux Bash Scripting - Command Chaining & Command lists

linux

# this is to show you how to execute a series of commands in one strike.


$ clear; cd /; ls -l; echo "You are in $PWD"; echo "Time to go back home"; cd ~;


# use semi colon between each command.


# There is also command lists, which is for a different logic


## double ampersand means ANDING, double pipe means ORING; when using &&, only when the first command exits 0 (successful), the later command will be proceeded; when using ||, if the first command exits none zero (not successful), the later command will be proceeded;


$ ls -l && you are in $PWD, you were in $OLDPWD


$ ls -z || you are in $PWD

Linux Bash Scripting - Command Chaining & Command lists