Multiple commands can be placed on a single line, and their execution depends on the delimiter used between the commands.
if each command is separated by a semicolon (;) is separated, the command executes continuously, such as :
Reference
[Email protected]:/proc> printf "%s/n" "This is executed"; printf "%s/n" "and so are This"
This is executed
And so are this
if each command is separated by a &&, then these commands will continue to execute, and if there is an error in the middle of the command, then the subsequent command is no longer executed, yes, then the execution is complete :
Reference
[Email protected]:/proc> date && printf "%s/n" "The date command was successful"
Friday, August 28, 2009 18:28:16 CST
The date command was successful
All commands are successfully executed.
Reference
[Email protected]:/proc> date && llk && printf "%s/n" "The date command was successful"
Friday, August 28, 2009 18:28:52 CST
Bash:llk:command not found
Subsequent successful execution prompt statements are not output because the LLK command is not recognized.
if each command is double vertical (| |) separators, if the command encounters a command that can be executed successfully, then the command stops executing, and all subsequent commands will not be executed, even after the correct command is followed. If the command fails at the beginning, it executes | | After the next command, until it encounters a command that can execute successfully, and if all fails, all of these failed commands are tried once :
Reference
[Email protected]:/proc> date | | LS/| | Date ' duck! ' | | Uname-a
Friday, August 28, 2009 18:33:18 CST
The first command executes successfully! All subsequent commands are no longer executed.
Reference
[Email protected]:/proc> date ' duck! ' | | DAKKK | | Uname-a
Date: Invalid Day "duck!"
Bash:dakkk:command not found
Linux linux-beyes 2.6.27.29-0.1-pae #1 SMP 2009-08-15 17:53:59 +0200 i686 i686 i386 gnu/linux
The previous two commands failed until the last command to execute successfully was found.
How Linux executes multiple commands in succession