Linux命令执行顺序— ||和和; 比较
生活随笔
收集整理的這篇文章主要介紹了
Linux命令执行顺序— ||和和; 比较
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Linux命令執(zhí)行順序— ||和&&和; command1 && command2: &&左邊的command1執(zhí)行成功(返回0表示成功)后,&&右邊的command2才能被執(zhí)行。
command1 || command2: 如果||左邊的command1執(zhí)行失敗(返回1表示失敗),就執(zhí)行&&右邊的command2。
command1;command2: 命令順序執(zhí)行 //第一個命令執(zhí)行不成功,第二個命令才執(zhí)行
[tough@toughhou shell]cata||touchacat:a:Nosuchfileordirectory[tough@toughhoushell] lsa getpath.sh //第一個命令執(zhí)行成功,第二個命令不執(zhí)行
[tough@toughhou shell]cata||touchb[tough@toughhoushell] lsa getpath.sh //只有第一個命令(touch a)執(zhí)行成功,才執(zhí)行第二個命令(touch b)[tough@toughhou shell]touch a && touch b [tough@toughhou shell] lsa b getpath.sh //因為第一個命令執(zhí)行不成功,所以第二個命令沒執(zhí)行
[tough@toughhou shell]cat a1 && touch c cat: a1: No such file or directory [tough@toughhou shell] lsa b getpath.sh //命令順序執(zhí)行
[tough@toughhou shell]$ pwd;more a;date/home/tough/shell123Sun Oct 13 10:24:55 CST 2013
剛才輸入命令 echo "This is file content, over!" > filename 竟然會出錯,提示:
bash: ?!": event not found
原來字符串中的!會被解析。如果不出錯的話呢,轉義!就可以了,如 \! ,
或者把雙引號改成單引號也行。
總結
以上是生活随笔為你收集整理的Linux命令执行顺序— ||和和; 比较的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 元气骑士天赋球作用
- 下一篇: 驾考宝典app最新版本