Sunday, March 18, 2012

Checking Arguments in Unix

Script with one argument to execute the further commands


if [ $# -ne 1 ]
then
   echo "Write your comments"
   exit -1 # exit the script
fi

$# stands for the number of arguments, it is number.
In if command you can change ne (not equal) to other comparing operator according to the requirements.
lt = Less than.
gt = Greater than.
le = Less than or equal.
ge = Greater than or equal.
eq= Equals.