Double Vertical Bar

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Double Vertical Bar (||)

The command shell interprets the (||) as the logical OR. This is opposite of logical AND. Means second command will execute only when first command will be a failure.


rm exm || file jtp.txt ; echo yes

Linux Double Vertical Bar1

Look at the above snapshot, by listing the Desktop, you can see there is a file 'exm' (We have highlighted it just to point it out). Now, we have given the command "rm exm || file jtp.txt ; echo yes". On passing this command, 'file jtp.txt' has not been executed because first command has sucessfully deleted 'exm'.

Now, again we have passed the same command "rm exm || file jtp.txt ; echo yes" and now second command 'file jtp.txt' is executed successfully.