diff options
-rw-r--r-- | bash.md | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -77,3 +77,14 @@ All keys: ${!array[*]} ${!array[@]} + +## Getopts example + + while getopts 'a:b:c' flag; do + case "${flag}" in + a) do_something $OPTARG ;; + b) b_option=$OPTARG ;; + c) c_flag=1 ;; + *) error "Unexpected option ${flag}" ;; + esac + done |