Created
May 6, 2019 05:45
-
-
Save jpcaparas/0a1583ffa91b77fe5a305e6c6c73a073 to your computer and use it in GitHub Desktop.
getopts example
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 | |
while getopts ":f:b:" o; do | |
case "${o}" in | |
f) | |
foo=${OPTARG} | |
;; | |
b) | |
bar=${OPTARG} | |
;; | |
esac | |
done | |
foo=${foo:-Foo!} | |
bar=${bar:-Bar!} | |
echo "${foo} and ${bar}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment