[dywang@dywmac ~]$ vim str.sh [dywang@dywmac ~]$ cat str.sh echo $str [dywang@dywmac ~]$ export str='abc' ; sh str.sh abc
[dywang@dywmac ~]$ ls /etc/dywang-release && cat /etc/dywang-release /etc/dywang-release De-Yu Wang Linux 6.4 release (Taiwan) [dywang@dywmac ~]$ ls /etc/dywang-release || cat /etc/dywang-release /etc/dywang-release
&&
及 ||
連續執行,若存在則顯示其內容,若不存在,則顯示產生空檔案 abcd,再次執行時檔案 abcd 已存在,顯示其內容為空的。
[dywang@dywmac ~]$ ls abcd && cat abcd || touch abcd ls: cannot access abcd: No such file or directory [dywang@dywmac ~]$ cat abcd [dywang@dywmac ~]$ ls abcd && cat abcd || touch abcd abcd