Created
June 3, 2012 09:02
-
-
Save ynonp/2862674 to your computer and use it in GitHub Desktop.
Case bash example
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
#!/usr/bin/env bash | |
# | |
# show | |
# Hello Mr. Anonymous. You work at UNKNOWN COMPANY | |
# | |
# show -name Mike | |
# Hello Mr. Mike. You work at UNKNOWN COMPANY | |
# | |
# show -job Intel | |
# Hello Mr. Anonymous. You work at Intel | |
# | |
# show -name Mike -job Intel | |
# Hello Mr. Mike. You work at Intel | |
# | |
NAME=Anonymous | |
JOB="UNKNOWN COMPANY" | |
while [[ $# -gt 0 ]] | |
do | |
case $1 in | |
-name) NAME=$2; shift 2;; | |
-job) JOB=$2; shift 2;; | |
*) echo "Unknown Argument: $1"; exit;; | |
esac | |
done | |
echo Hello Mr $NAME. You work at $JOB | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment