Shell Script to find if a number is positive or negative or zero
Program
echo "Enter a number:"
read a
if [ $a -eq 0 ]
then
echo "$a is neither postive nor negative"
elif [ $a -gt 0 ]
then
echo "$a number is positive"
else
echo "$a number is negative"
fi
Output 1
$ chmod 755 positive-negative-zero.sh
$ ./positive-negative-zero.sh
Enter a number:
5
5 number is positive
Output 2
$ chmod 755 positive-negative-zero.sh
$ ./positive-negative-zero.sh
Enter a number:
-124
-124 number is negative
Output 3
$ chmod 755 positive-negative-zero.sh
$ ./positive-negative-zero.sh
Enter a number:
0
0 is neither postive nor negative