A quick glimpse:
A ; B
: Run A and then B, regardless of the success of AA && B
: Run B if A succeededA || B
: Run B if A failed
&&
It is often to see commands are written in one line, such as
$ command A && command B
The intent is to execute command B
after command A
only if command A
is executed successfully. In this way, commands are chained together, such that the next command is run if and only if the preceding command exited without errors.
||
on the contrary, If two commands are chained by a ||
, such as
$ command A || command B
It means command B
will be executed only if Command A
doesn't runs successfully (exit status is false).
;
;
is just a separator which doesn't care what happened to the command before.
command A ;
command B
\
\
is used at the end of a line, as a means of concatenating lines together and run as a single command. So the following two commands are processed exactly the same.
this \
is command A
is the same as
this is command A
References:
bash — Confusing use of && and || operators — Unix & Linux Stack Exchange https://unix.stackexchange.com/questions/24684/confusing-use-of-and-operators