The && operator syntax is formatted as follows: Command1 && command2 [&& Command3 ...] 1. Use && connection between commands to implement logic and functions. 2. Only the command on the left of && returns True (command return value $?). = = 0) The command to the right of,&& will be executed. 3. As long as there is a command return False (command return value $?) = = 1), the subsequent command will not be executed. | Operator: Command1 | | command2| | is the opposite of &&. if | | The command on the Left (Command 1) did not execute successfully, then execute | | The command on the right (command 2), or in other words, "If this command fails to execute | | Then execute this command. 1 Use between commands | | A connection that implements logic or functionality. 2 Only in | | The left command returns False (the command returns a value of $?). = = 1), | | The command on the right will not be executed. This is the same as the logical or syntactic function in C, which is to implement short-circuit logic or operations. 3 As long as there is a command return True (command return value $?) = = 0), the subsequent command will not be executed.
Shell Basic Command && and | |