67
Combining && and ||
The combination of logical AND and logical OR is used to write an if then else structure in the command line.
If first condition (if) will be fulfilled then command line execution stops there.
But if first condition is a failure, then second one (else) executes.
Example:
Look at the above snapshot, from command “cd Desktop && file jtp.txt || echo successful.”, first (if) command (cd Desktop && file jtp.txt) is successfully executed and hence command line execution stops.
But second time, ‘if’ part execution is unsuccessful, hence ‘else’ part will be executed.
Next TopicPound Sign