Special Symbol:&&
Note: Also, the left and right sides are two commands, the execution on the left will only execute the command on the side. Right
Special Symbols: | |
Note: Alternatively, the left and right sides are two commands, the command on the other side is unsuccessful to execute the command
&&
[[email protected] 111]# ls 1.txt && ls 2.txt//Before and after successful execution
1.txt
2.txt
[[email protected] 111]# ls 10.txt && ls 2.txt//Front execution failed, back not executed
LS: Unable to access 10.txt: No file or directory
[[email protected] 111]# ls 1.txt && ls 20.txt//Previous execution succeeded, subsequent execution failed
1.txt
LS: Unable to access 20.txt: No file or directory
||
[[email protected] 111]# ls 1.txt | | LS 2.txt
1.txt
[[email protected] 111]# ls 10.txt | | LS 2.txt
LS: Unable to access 10.txt: No file or directory
2.txt
[[email protected] 111]# ls 1.txt | | LS 20.txt
1.txt
////////////////////////////////////////////////////////////////
Summary:&& and | | Or both are commands for logical judgment.
&& for the left condition to succeed, execute the command on the right, the left condition is not true, then do not execute
|| For the left side of the condition is not set to try to try the right, the left side of the condition is set, then the right does not execute
The command on the left side executes successfully, executing the command on the right.
Shell Getting Started-connectors (and, and, or)