Conditional execution

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← The exit status of a commandHomeLogical AND →

You can link two commands under bash shell using conditional execution based on the exit status of the last command. This is useful to control the sequence of command execution. Also, you can do conditional execution using the if statement. The bash support the following two conditional executions:

  1. Logical AND && - Run second command only if first is successful.
  2. Logical OR || - Run second command only if first is not successful.
← The exit status of a commandHomeLogical AND →