What Does || Do in Linux?
Contents

The || represents a logical OR. The second command is executed only when the first command fails (returns a non-zero exit status). Here is another example of the same logical OR principle. You can use this logical AND and logical OR to write an if-then-else structure on the command line.

What does || mean in Linux?

|| means execute the statement which follows only if the preceding statement failed (returned a non-zero exit code).

What is || in shell script?

The OR Operator (||) is much like an ‘else’ statement in programming. The above operator allow you to execute second command only if the execution of first command fails, i.e., the exit status of first command is ‘1’.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest