Reputation: 123
can anybody tell me what is the difference between
cmd1 & cmd2 & ...
and
cmd1 && cmd2 && ....
in shell scripting. If they differ in execution may I know how each commands are actually get executed.
Upvotes: 2
Views: 2937
Reputation: 13971
Assume there are cmd1 && cmd2. command2 will be executed if and only if command1 returned zero exit status.
Upvotes: 0
Reputation: 172438
cmd & means "run command in the background."
cmd1 && cmd2 means "run cmd1 and if it completes successfully, run cmd2 afterwards." So its like cmd2 will only be executed if cmd1 succeeds.
Upvotes: 5