how to compare real/float while using "AND" .(unix) -
i'm new shell scripting, have written small script check if input in specified (integer) range:
echo "enter number btw 50 , 100:" read num if [ $num -le 100 -a $num -ge 50 ]; echo "you in limits." else echo "you out of limits." fi
how can check if number in real/floating range?
you can't sh/ksh1/bash(/zsh?) -- integer arithmetic only.
you can like
if [ "$(echo "50 <= $num && $num <= 100" | bc)" = "1" ]; echo "you in limits." else echo "you out of limits." fi
(1 - ksh93 can floating point arithmetic)