Created
September 8, 2012 15:46
-
-
Save turbod/3676227 to your computer and use it in GitHub Desktop.
Processing options and parameters with getopts
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/zsh | |
# processing options and parameters with getopts | |
while getopts :a:b:cd opt | |
do | |
case "$opt" in | |
a) echo "The -a option, value $OPTARG";; | |
b) echo "The -b option, value $OPTARG";; | |
c) echo "The -c option";; | |
d) echo "The -d option";; | |
*) echo "Unknown option: $opt";; | |
esac | |
done | |
shift $[ $OPTIND - 1 ] | |
count=1 | |
for param in "$@" | |
do | |
echo "Parameter $count: $param" | |
count=$[ $count + 1 ] | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment