Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 349 Bytes

File metadata and controls

27 lines (24 loc) · 349 Bytes

Bash getopts

Back

getopts in bash is similar to getopt.h

while getopts "a:bh?" opt
do
  case "$opt" in
  [h?])
    echo "-h passed"
    exit 0
    ;;
  a)
    echo "Argument -a received with $OPTARG"
    ;;
  b)
    echo "Argument -b received"
    ;;
  *)
    echo "Default"
    exit 1
    ;;
  esac
done