Last active
December 21, 2020 06:19
-
-
Save andreas22/c58fae399096c07ac0b32acf18029aa3 to your computer and use it in GitHub Desktop.
Template that can be used for creating a bash script with named parameters and help instructions
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 | |
# Initialize argument values | |
follow="" | |
tail="" | |
version="1.0.0" | |
help() { | |
echo "(Version: ${version}) Usage: $0 [ARGUMENTS]" | |
echo | |
echo "Add description of the script functions here." | |
echo | |
echo "Argument(s) Description" | |
echo "-----------------------------------------------" | |
echo "-h | --help Show these help instructions." | |
echo | |
echo "-f | --follow My description." | |
echo "-t | --tail My description." | |
echo | |
echo "Created by Andreas Christodoulou<andreas22[@]gmail[.]com> at 2020-12-19" | |
exit 0 | |
} | |
if [[ "$#" -eq 0 ]]; then | |
help | |
fi | |
# Set argument values | |
while [[ "$#" -gt 0 ]] | |
do | |
case $1 in | |
-f|--follow) | |
follow=$2 | |
;; | |
-t|--tail) | |
tail=$2 | |
;; | |
-h|--help) | |
help | |
;; | |
esac | |
shift | |
done | |
# Run | |
echo "Follow: $follow" | |
echo "Tail: $tail" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment