Linux Shell Scripting Tutorial (LSST) v1.05r3
Chapter 4: Advanced Shell Scripting Commands
The syntax for OR list as follows
command1 || command2
command2 is executed if and only if command1 returns a non-zero exit status.
You can use both as follows
command1 && comamnd2 if exist status is zero || command3 if exit status is non-zero
if command1 is executed successfully then shell will run command2 and if command1 is not successful then command3 is executed.
$ rm myf && echo "File is removed successfully" || echo "File is not removed"
If file (myf) is removed successful (exist status is zero) then "echo File is removed successfully" statement is executed, otherwise "echo File is not removed" statement is executed (since exist status is non-zero)
|Local and Global Shell variable (export command)|| |
I/O Redirection and file descriptors