if statement in loop bash script code example
Example 1: bash if statement
and - &&
or - ||
# and example
if [ -r $1 ] && [ -s $1 ]
then
echo This file is useful.
fi
# or example
if [ $USER == 'bob' ] || [ $USER == 'andy' ]
then
ls -alh
else
ls
fi
Example 2: bash loop with if
-eq # equal
-ne # not equal
-lt # less than
-le # less than or equal
-gt # greater than
-ge # greater than or equal