How do i use command line conditionals on the bash shell prompt?
-
|| means OR in boolean
&& mean AND in boolean
These are used on the command line to decide if a condition is met.
if the left side of the
||
is not true, then run the right side of the||
For example:
$ test -d /var/log/samba || echo "Samba log directory does not exist" Samba log directory does not exist
The && on the bash shell does the opposite if the left side of the && is true, then run the right side of the &&
For example:
$ test -d /var/log && echo "Log directory does exists" Log directory does exists
© Lightnetics 2024