mercredi 22 février 2017

How can I compare variable with constant in bash?

I have two constants declared with

readonly MIN=1
readonly MAX=100

I want to compare if a variable num is less than MIN or greater than MAX. So I made

if [[ $num -lt $MIN || $num -gt $MAX ]] ; then
    # Do something
fi

But in script this not work.

How do I compare a variable with a constant declared with readonly?

Aucun commentaire:

Enregistrer un commentaire