Skip to content

Instantly share code, notes, and snippets.

@jpcaparas
Created May 7, 2019 21:46
Show Gist options
  • Save jpcaparas/0531fdce2d56f3cee0951d04ff3bc7e4 to your computer and use it in GitHub Desktop.
Save jpcaparas/0531fdce2d56f3cee0951d04ff3bc7e4 to your computer and use it in GitHub Desktop.
getopts long options
#!/bin/bash
optspec=":-:"
while getopts "${optspec}" optchar; do
case "${optchar}" in
-)
case "${OPTARG}" in
*)
value=${OPTARG#*=}
opt=${OPTARG%=$value}
echo "You passed --${opt} as a flag with the value ${value}"
;;
esac
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment