Created
May 7, 2019 21:46
-
-
Save jpcaparas/0531fdce2d56f3cee0951d04ff3bc7e4 to your computer and use it in GitHub Desktop.
getopts long options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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