passing parameters to the script

how can i make a script to run only when parameters are given,
if parameters are not given it should through an error , saying "please enter a parameter"

for ex: i want a find command to run only when the parameters are given

if $# is 0, it means no parameters were passed to the script.

Thanks For Clue,sorted it out:)

Another way to test:

if [ "$1" = '' ]; then 
#no arguments given, exit
fi

@tukuyomi:

$ cat test.sh
echo "\$# \"$#\""
echo "\$1 \"$1\""
echo "\$2 \"$2\""
if [ "$1" = '' ]; then 
  echo no arguments given
fi

$ ./test.sh
$# "0"
$1 ""
$2 ""
no arguments given

$ ./test.sh "" 2
$# "2"
$1 ""
$2 "2"
no arguments given
1 Like