Return to Snippet

Revision: 51240
at September 19, 2011 02:49 by 4fthawaiian


Initial Code
while true; do
    case "$1" in
      -h|--help|-\?) show_help; exit 0;;
      -v|--verbose) verbose=1; shift;;
      -a) if [ $# -gt 1 ]; then
            UNAME=$2; shift 2
          else 
            echo "-a requires an argument" 1>&2
            exit 1
          fi ;;
      --) shift; break;;
      -*) echo "invalid option: $1" 1>&2; show_help; exit 1;;
      *)  break;;
    esac
done

Initial URL
http://mywiki.wooledge.org/BashFAQ#BashFAQ.2BAC8-035.How_can_I_handle_command-line_arguments_.28options.29_to_my_script_easily.3F

Initial Description


Initial Title
bash command line args

Initial Tags
Bash

Initial Language
Bash