Linux Bash Scripting - Command Chaining & Command lists

 # 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章