Add A Help Dialog To Bash Scripts

Below is a quick and simple case statement that functions as a help dialog whenever the script is run with -h, –help, or -help.

Code snippet:


# Help dialog
case "$1" in
-h|--help|-help) # Argument to check for
  # If help argument was passed then run this
  print "This is a sample help dialog created using a simple case statement,\n";
  print "for more information on case statements please visit";
  exit 0; # Exit cleanly after showing help dialog.

I hope this quick post was useful for you, please don’t forget to like/share/comment. Thanks!

Leave a Reply

Protected with IP Blacklist CloudIP Blacklist Cloud