Linux continuously execute multiple commands

Quoted from: here

Each command uses ";" separated, regardless front of the command is successful or not will continue to execute a command
here, deliberately second command echo write a o, command execution errors, but does not affect execution of subsequent commands
may think so, if the interval command with a semicolon, the equivalent of the command separator in a different line, regardless of the previous line of command success or failure will not affect the next line command.
1 echo $;  echoo 2 ; 3 echo; echo 4
1
-bash: echoo: the Command not found
3
4

if between commands using the "&&" separated, only the front of the command is successful then the command will proceed back
here, willfully the second command echo write a o, command execution errors, echo 3 there will be no execution, therefore echo4 did not execute
$ 1 && echo  echoo 2  && echo && echo 3 4
1
-bash: echoo: the command not found

If the inter-command "||"




 Echo echo. 3 2 || || || echo. 4
-bash: echoo: Command Not found
2

Analyzes of several more specific example of the above rules, i.e. a mixture of concentrated example delimiter
echo 1 successfully performed, followed behind there are two "||" So echo 2, echo 3 did not execute, met behind &&, and before that command combination is considered to be executed successfully, and therefore able to perform echo 4
$ echo 1 || echo 2 || echo && echo. 4. 3 
. 1
. 4

echo 1 execution is successful, then execute echoo 2, was unsuccessful, it echoes 3 is not executed, met behind "||", before conceivable combination of command is considered failed, so the echo 4 to be executed

1 && echo $  echoo 2  && || echo echo 3 4
1
-bash: echoo: the Command not found
4

echo 1 executed successfully, and then execute echoo 2, was unsuccessful, echo 3 is not executed, behind encountered a ";" , corresponding to the command back into a new row, in which case the commands are executed in any case behind, to be performed so echo 4
$ echo. 1 &&  echoo 2  && echo. 3; echo 4
. 1
-bash: echoo: command Not found
. 4

echoo 1 fails, back to "||" So echo 2 to be executed, echo 2 is successful, followed behind the two "||" So echo 3, echo 4 is not performed, met behind &&, and combinations of commands before is considered to be executed successfully, so echoo5 be executed, execution error occurs, and therefore echo 6 is not executed, but is behind ";" so anyway echo 7 will be executed
$  echoo 1  || 2 || echo echo 3 | | && echo. 4  echoo. 5  && echo. 6; echo. 7
-bash: echoo: Command Not found
2
-bash: echoo:command not found
7

Guess you like

Origin www.cnblogs.com/yunlongaimeng/p/11571030.html