When using "&&", only Command1 execution succeeds, Command2 will execute, otherwise command2 not execute; [[email protected] ~]# ls 1.txt && ls 2. Txt1.txt2.txt[[email protected] ~]# ls 1.txt && ls 20.txt1.txtls: Inaccessible 20.txt: No file or directory
When using "| |", the Command1 execution succeeds Command2 not execute, otherwise go to execute Command2, in short Command1 and Command2 always have a command to execute.
[[email protected] ~]# ls 1.txt | | LS 20.txt1.txt[[email protected] ~]# ls 10.txt | | LS 20.txtls: Inaccessible 10.txt: No file or directory LS: unable to access 20.txt: No file or directory [[email protected] ~]# ls 10.txt | | LS 1.txtls: Inaccessible 10.txt: No file or directory 1.txt
When using ";", Command2 will be executed regardless of whether Command1 is executed successfully;
[email protected] ~]# ls 10.txt; LS 1.txtls: Inaccessible 10.txt: No file or directory 1.txt
This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1759975
Connectors in the shell (and, and, or)