[How To] Writing OR condition for String Comparison

[Unix] Writing OR condition for String Comparison

The trivial method is to use '-o' in the if-then-else-fi condition. ‘-o’ stands for 'or'.

The same is exemplified the below shell script.

if [ "$1" = 'Sunday' -o "$1" = 'Monday' -o "$1" = 'Tuesday' -o "$1" = 'Wednesday' -o "$1" = 'Thursday' -o "$1" = 'Friday' -o "$1" = 'Saturday'  ]; then
    echo "You have entered a Day of Week"
else
    echo "You have NOT entered a Day of Week" 
fi;

click on the image to enlarge