Posted By

triffel on 08/08/12


Tagged

Bash unix linux


Versions (?)

Correct Number of Parameters


 / Published in: Bash
 

Tests whether the script has been invoked with the correct number of parameters.

  1. E_WRONG_ARGS=85
  2. script_parameters="-a -h -m -z"
  3. # -a = all, -h = help, etc.
  4. if [ $# -ne $Number_of_expected_args ]
  5. then
  6. echo "Usage: `basename $0` $script_parameters"
  7. # `basename $0` is the script's filename.
  8. exit $E_WRONG_ARGS
  9. fi

Report this snippet  

You need to login to post a comment.