Home Linux Bash

#!/bin/bash

usage()
{
cat << EOF
usage: $0 options

OPTIONS:
   -h      Show this message
   -t      Test type, can be test1 or test2
   -r      Server address
   -p      Server root password
   -v      Verbose
EOF
}

TEST=
SERVER=
PASSWD=
VERBOSE=
while getopts h:t:r:p:vĚ OPTION
do
     case $OPTION in
         h)
             usage
             exit 1
             ;;
         t)
             TEST=$OPTARG
             ;;
         r)
             SERVER=$OPTARG
             ;;
         p)
             PASSWD=$OPTARG
             ;;
         v)
             VERBOSE=1
             ;;
         ?)
             usage
             exit
             ;;
     esac
done





options with ":" after means that they need to have an argument and "!" means the option is mandatory.
The colon in front of the string turns off error-messages.