'I'm using this shell script to identify the maximum and minimum of the performed arithmetic operation but facing issue with float value in if block
read -p "enter first number : " a
read -p "enter second number : " b
read -p "enter third number : " c
if [ $b -gt 0 ]
then
w=`echo $a $b $c | awk '{print $1+$2*$3}'`;
echo $w;
x=`echo $a $b $c | awk '{print $1%$2+$3}'`
echo $x
y=`echo $c $a $b | awk '{print $1+$2/$3}'`
echo $y
z=`echo $a $b $c | awk '{print $1*$2+$3}'`
echo $z
if [ $w -gt $x ] && [ "($w -gt $y | bc)" ] && [ $w -gt $z ]
then
echo $w"w"
elif [ $x -gt $w ] && [ "( $x -gt $y | bc )" ] && [ $x -gt $z ]
then
echo $x"x"
elif [ $z -gt $w ] && [ $z -gt $x ] && [ "($z -gt $y | bc)" ]
then
echo $z"z"
else
echo $y"y"
fi
if [ $w -lt $x ] && [ "( $w -lt $y | bc )" ] && [ $w -lt $z ]
then
echo $w"w"
elif [ $x -lt $w ] && [ "( $x -lt $y | bc )" ] && [ $x -lt $z ]
then
echo $x"x"
elif [ $z -lt $w ] && [ $z -lt $x ] && [ "($z -lt $y | bc )" ]
then
echo $y"y"
else
echo $z"z"
fi
fi
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
