MJN All Blog Cheatsheets Elasticsearch GCP JS LinuxBash Misc Notes Other ShortcutKeys / - Search

Home / LinuxBash / Script bash-script-example - Example Bash Script


#!/bin/bash
help_text="
NAME
  bash-func - One line description.

USAGE
  bash-func [options] <parameters>

OPTIONS
  -x
    Description...

  -h|--help
    Show help text.

DESCRIPTION
  Description description description description.

AUTHOR
  mjnurse.dev - 2020
"
help_line="tbc"
web_desc_line="Example Bash Script"

try="Try ${0##*/} -h for more information"
tmp="${help_text##*USAGE}"
usage=$(echo "Usage: ${tmp%%OPTIONS*}" | tr -d "\n" | sed "s/  */ /g")

if [[ "$1" == "" ]]; then
  echo "${usage}"
  echo "${try}"
  exit 1
fi

while [[ "$1" != "" ]]; do
  case $1 in
    -h|--help)
      echo "$help_text"
      exit
      ;;
    ?*)
      break
      ;;
  esac
  shift
done


This page was generated by GitHub Pages. Page last modified: 23/08/03 09:22