Skip to content

Instantly share code, notes, and snippets.

@bsnux
Created July 8, 2020 21:00
Show Gist options
  • Save bsnux/73c9112878e5153cb8421f1bac4658c7 to your computer and use it in GitHub Desktop.
Save bsnux/73c9112878e5153cb8421f1bac4658c7 to your computer and use it in GitHub Desktop.
Simple template for shell scripts
#!/bin/bash
# help-template.sh
#
# Simple template for shell scripts
#
Help=$(cat <<-"HELP"
my-script — does one thing well
Usage:
my-script <input> <output>
Options:
<input> Input file to read.
<output> Output file to write. Use '-' for stdout.
-h Show this message.
HELP
)
help() {
echo "$Help"
}
if [[ $# == 0 ]] || [[ "$1" == "-h" ]]; then
help
exit 1
fi
echo "Hello World"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment