Skip to content

Instantly share code, notes, and snippets.

@graemearthur
Created September 13, 2012 22:21
Show Gist options
  • Save graemearthur/3718142 to your computer and use it in GitHub Desktop.
Save graemearthur/3718142 to your computer and use it in GitHub Desktop.
Bash Shell Script Template
#!/bin/bash
# Author: Craig Russell
# Email: craig@craig-russell.co.uk
# 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"
@giper45
Copy link

giper45 commented Apr 15, 2017

Hi ! How to if I have arguments with spaces ? Any advice ? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment