Created
April 12, 2012 07:38
-
-
Save atton/2365464 to your computer and use it in GitHub Desktop.
shell script option test
This file contains hidden or 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/sh | |
# shell script option test | |
a=0 | |
b=0 | |
while getopts ab opt | |
do | |
case ${opt} in | |
a) | |
a=1 ;; | |
b) | |
b=1 ;; | |
esac | |
done | |
if [ $a -eq 1 ] ; then | |
shift | |
echo option a | |
fi | |
if [ $b -eq 1 ] ; then | |
shift | |
echo option b | |
fi | |
if [ $a -eq 0 ] ; then | |
if [ $b -eq 0 ] ; then | |
echo option none | |
fi | |
fi | |
echo $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment