Validation help

Hi,

I am new to Unix shell scripting and need help to add some validation to an existing script.

I've made a script that takes two argument (input) but I want the script to display an error message when nothing (null) is entered. So far I managed to validate the fist argument but fail to validate the second input.

I have this so far

if [ $# -eq 0 ]
then
echo "run the script again and pass in a value"
exit 0
fi

Many Thanks

Hi.

If you said:

if [ $# -lt 2 ]
  ...
fi

Then the script would need at least two arguments to continue. Is that not what you wanted?

if [ $# -ne 2 ]
  ...
fi

would mean exactly two arguments were required.

Thanks for your help, both works fine and is the 2nd one that i needed.