check for arguments in shell script

by RameshKumar 2010-01-23 14:48:45


if [ $# -eq 0 ]
then
echo "Error - Number missing form command line argument"
echo "Syntax : $0 number"
echo "Use to print multiplication table for given number"
exit 1
fi


These code's will check for the number of arguments passed from the command line


if [ $# -gt 0 ]
then
echo "Error - Number missing form command line argument"
echo "Syntax : $0 number"
echo "Use to print multiplication table for given number"
exit 1
fi

Tagged in:

735
like
0
dislike
0
mail
flag

You must LOGIN to add comments