CMD1 && cmd2 If the command cmd1 result status 0, the CMD2 is executed, otherwise the CMD2 command is not executed.
cmd1 | | CMD2 if the command cmd1 result status 1, the CMD2 is executed, otherwise the CMD2 command is not executed.
can be used for exception handling:
I.e: Run the CMD1 command and output a message if the CMD1 is running wrong.
Adb-s "Device" Logcat | | {echo "Device not found"; exit 1;}
Explanation: If the command adb-s "device" Logcat execute an error, the user is prompted to "device not found."
i.e:
As the following command:
[[E File1]] && echo "file1 file exits." | | Touch File1
The first time the command is executed, the result status of the [[E-file1] command is 1 when there is no file1 file under the current command, and the command echo "File1 file exits" is not executed, and for the Touch file1 command, due to the previous Action ([[E File1]] && echo "file1 file exits." The result status is 1, so the touch file1 is executed
But when the command is run the second time, the [[E-file1]] command returns 0, then the echo "File1 file exits" is executed without performing the touch file1 command.