Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while getopts 'a:b:' opt; do
- case "$opt" in
- a) printf 'Got a: "%s"n' "$OPTARG" ;;
- b) printf 'Got b: "%s"n' "$OPTARG" ;;
- *) echo 'error' >&2
- exit 1
- esac
- done
- shift $(( OPTIND - 1 ))
- printf 'Other argument: "%s"n' "$@"
- $ bash script.sh -a hello -- -b world
- Got a: "hello"
- Other argument: "-b"
- Other argument: "world"
Add Comment
Please, Sign In to add comment