|
Parameter Checking
Hi all,
My script has 2 mandatory and 1 optional paramter. If the third parameter(optional) one is null the it should take a default value say 3. Can any one please write a simple code.
sh test.sh 1 2 3
var1=$1
var2=$2
if [ -z $3 ]
then
var3=3
fi
echo " the third variable $var3"
But this is erroring out saying " test.sh: test: argument expected"
Thanks in advance
Ammu
|