Check if a number is within a range in bash

Posted on June 1, 2020 at 5:49 pm

Bash snippet to check if a number is within a range:

number=3
 
if [ "$number" -ge 2 ] && [ "$number" -le 5 ]; 
then
    echo "$number is within 2 and 5"
fi

Receive updates via email

Other Posts

Updated Posts