Created
September 13, 2012 22:21
-
-
Save graemearthur/3718142 to your computer and use it in GitHub Desktop.
Bash Shell Script Template
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 | |
# Author: Craig Russell | |
# Email: [email protected] | |
# Date: yyyy-mm-dd | |
# Usage: script.sh [-a|--alpha] [-b=val|--beta=val] | |
# Description: | |
# | |
# | |
# | |
# Defaults # | |
A=false | |
B="Foo" | |
# Parse Parameters # | |
for ARG in $*; do | |
case $ARG in | |
-a|--alpha) | |
A=true | |
;; | |
-b=*|--beta=*) | |
B=${ARG#*=} | |
;; | |
*) | |
echo "Unknown Argument $ARG" ;; | |
esac | |
done | |
# Do Some Stuff # | |
echo "Usage script.sh [-a|--alpha] [-b=val|--beta=val]" | |
echo "A: $A" | |
echo "B: $B" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi ! How to if I have arguments with spaces ? Any advice ? Thanks!