Created
November 23, 2013 17:42
-
-
Save khaledmdiab/7617635 to your computer and use it in GitHub Desktop.
parses command line arguments
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/bash | |
FILENAME="" | |
DIRNAME="" | |
while [ $# -gt 0 ]; | |
do | |
case $1 in | |
(-h|--help) usage ;; | |
(-v|--version) version ;; | |
(-f|--filename) | |
FILENAME=$2; | |
shift 2;; | |
(-d|--dirname) | |
DIRNAME=$2; | |
shift 2;; | |
(--) shift; break;; | |
(-*) echo "$1: unknown option"; usage ;; | |
(*) break;; | |
esac | |
done | |
echo $FILENAME | |
echo $DIRNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment