Last active
July 30, 2018 03:16
-
-
Save kenbarbour/99ec639bf08d932793e4d04cde3149df to your computer and use it in GitHub Desktop.
A basic skeleton bash script with a usage statement
This file contains 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 | |
## | |
## Skeleton Script that does nothing useful. This is the script that I copy | |
## when I make other scripts. | |
## | |
## Usage: _PROG_ [OPTIONS] | |
## | |
## Options: | |
## -h --help Display help message and exit | |
## | |
prog="$0" | |
me=`basename "$prog"` | |
dohelp(){ | |
grep '^##' "$prog" | sed -e 's/^##\s\?//' -e "s/_PROG_/$me/" 1>&2 | |
exit | |
} | |
if [ "$1" = "-h" -o "$1" = "--help" ] ; then | |
dohelp | |
fi | |
# Do the script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For some more details on this method of self-documenting bash scripts, see this article from Linux Daily: http://www.thelinuxdaily.com/2012/09/self-documenting-scripts/