Last active
September 16, 2024 17:12
-
-
Save bertvv/7727082 to your computer and use it in GitHub Desktop.
Simple Bash script template
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 | |
# | |
# Script name -- purpose | |
# | |
# Author: | |
set -o errexit # abort on nonzero exitstatus | |
set -o nounset # abort on unbound variable | |
set -o pipefail # don't hide some errors in pipes | |
# | |
# Functions | |
# | |
# Print usage info | |
usage() { | |
cat << _EOF_ | |
Usage: ${0} | |
_EOF_ | |
} | |
# | |
# Variables | |
# | |
# | |
# Command line parsing | |
# | |
if [ "$#" -ne "1" ]; then | |
echo "Expected 1 argument, got $#" >&2 | |
usage | |
exit 2 | |
fi | |
# | |
# Script proper | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Het commando op lijn 30 drukt een foutboodschap af, dus het is nuttig dit naar stderr af te drukken om een onderscheid te maken met de "normale" output van het script.