Created
March 9, 2016 07:40
-
-
Save cdpath/4b4994c3275fa1e6868d to your computer and use it in GitHub Desktop.
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 | |
echo "OPTIND starts at $OPTIND" | |
while getopts ":pq:" optname | |
do | |
case "$optname" in | |
"p") | |
echo "Option $optname is specified" | |
;; | |
"q") | |
echo "Option $optname has value $OPTARG" | |
;; | |
"?") | |
echo "Unknown option $OPTARG" | |
;; | |
":") | |
echo "No argument value for option $OPTARG" | |
;; | |
*) | |
# Should not occur | |
echo "Unknown error while processing options" | |
;; | |
esac | |
echo "OPTIND is now $OPTIND" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment