How do I use logical or/and in bash shell scripts?
-
Logical OR is
||
and Logical AND is&&
Used to compare many conditions in a shell script.
The first condition uses logical OR and the second logical AND.
$ cat bitwise.sh if ((10 == 10)) || ((10 > 2));then echo "One of us is right" fi if ((10 == 9)) && ((10 > 2));then echo "We're both right" fi
Running the script give the following result:
$ ./bitwise.sh One of us is right
© Lightnetics 2024