Javatpoint Logo
Javatpoint Logo

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:

Linux Combining && and ||

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA