Created
June 17, 2019 03:58
-
-
Save jason51285128/468635d96cac028f1bd65e14da5ffff7 to your computer and use it in GitHub Desktop.
use ##short option in bash ##
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 | |
help() | |
{ | |
cat << HERE | |
usage: ./opt.sh -a {value} -b {value} -c {value} -d {value} -h | |
HERE | |
} | |
while getopts "a:b:c:d:h" arg | |
do | |
case $arg in | |
a) | |
echo "option a is $OPTARG" | |
;; | |
b) | |
echo "option b is $OPTARG" | |
;; | |
c) | |
echo "option c is $OPTARG" | |
;; | |
d) | |
echo "option d is $OPTARG" | |
;; | |
h) | |
help | |
exit 0 | |
;; | |
?) | |
help | |
exit 1 | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment