In a Bash script I want to check if var1 is located between var2 and var3. But I can't find how to do it.
Something like this.
var1=15
var2=10
var3=20
if [ "$var1" is located beetween "$var2" and "$var3" ]
then
echo "ok"
else
echo "not ok"
fi
Can you help me please ?
Thank you.
Assuming that the values are always numeric and by "var1 located between var2 and var3" you mean that
var2 < var1 < var3
, you can use this:Your logic is pointless... After all the code in the script is static, so when you change anything in the variables, you can adjust the logic in the rest of the script.