Bash shell script to check a given number is positive or negative
kw.sh
#!/bin/bash

echo "———————————————————————————————————————————"
echo "Script to check a given number is +ve or -ve "
echo "———————————————————————————————————————————"
echo "Enter the number \c"; read a
b=0
if [ $a -gt $b ];then
    echo "Entered number is positive"
elif [ $a -eq $b ];then
    echo "Entered number is zero"
else
    echo "Entered number is negative"
fi
echo "———————————————————————————————————————————"
Output
kodingwindow@kw:~$ bash kw.sh
———————————————————————————————————————————
Script to check a given number is +ve or -ve 
———————————————————————————————————————————
Enter the number -50
Entered number is negative
———————————————————————————————————————————

kodingwindow@kw:~$ sh kw.sh
———————————————————————————————————————————
Script to check a given number is +ve or -ve 
———————————————————————————————————————————
Enter the number 0
Entered number is zero
———————————————————————————————————————————
kodingwindow@kw:~$ 
Advertisement