check for arguments in shell script
by RameshKumar[ Edit ] 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