0

Cannot find anywhere documentation on -o in if conditional statement in bash. Please suggest documentation.

l00p
  • 392
  • 2
  • 17
  • 1
    There is no "if conditional statement". `if` executes the body if the _command_ returns with a zero exit status. There is a `[` or `test` command, and it's documentation is [posix test](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html) or [bash conditional expression](https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html). – KamilCuk Feb 03 '20 at 13:04
  • Wherever you find that option, modify it and use multiple `test` constructs instead of that. Even the POSIX page recommends that i.e. `test expr1 -o expr2 ` should be replaced with `test expr1 || test expr2` – Inian Feb 03 '20 at 13:06

1 Answers1

0

If you want to use if with two conditions in OR logical relation you can use code like this:

if [ $a -eq 3 ] || [ $b = "c" ]

for AND logical relation this must be

if [ $a -eq 3 ] && [ $b = "c" ]
Romeo Ninov
  • 6,538
  • 1
  • 22
  • 31