Notes

Showing Help and Usage

Edit on GitHub


Bash Scripting

A basic way is saving usage as a function

1showUsage() {
2    echo -e "Usage: please provide an argument"
3}

and later in your script, you can run a conditional statement that checks for something, say no arguments are provided, you can show the usage and exit

1if [ condition ]
2then
3  showUsage
4  exit 1
5else
6  # run the code
7fi