If Else With Multiple Conditions

Create Variable

age=23

Check Greater Than 17 And Less Than 30

To combine conditional tests with “and” use &&.

if (( "$age" > 17  && "$age" < 30 )); then
    echo "Greater than 17 and less than 30"
else
    echo "Not greater than 17 and less than 30"
fi
Greater than 17 and less than 30

Check Greater Than 17 Or Less Than 20

To combine conditional tests with “or” use ||.

if (( "$age" > 17 || "$age" < 30)); then
    echo "Greater than 17, or less than 30"
else
    echo "Not greater than 17 or less than 30"
fi

Greater than 17 or less than 30