Skip to content

Instantly share code, notes, and snippets.

@jan-swiecki
Created April 13, 2022 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jan-swiecki/0c0fa438352081c9f461bbf2801018ca to your computer and use it in GitHub Desktop.
Save jan-swiecki/0c0fa438352081c9f461bbf2801018ca to your computer and use it in GitHub Desktop.
bash_args_parse_example.sh
#!/bin/bash
usage () {
cat<<EOF
usage: ...
EOF
}
while [[ "$#" -gt 0 ]]; do
case $1 in
--xyz) xyz=1 ;;
--asd) asd="$2"; shift ;;
--key) value="$2"; shift ;;
--version) version=1 ;;
*) usage; exit 1 ;;
esac
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment