Skip to content

Instantly share code, notes, and snippets.

@gideonaina
Last active July 20, 2020 15:32
Show Gist options
  • Save gideonaina/2d5caf3f5ae5b8c098b7388254b36b34 to your computer and use it in GitHub Desktop.
Save gideonaina/2d5caf3f5ae5b8c098b7388254b36b34 to your computer and use it in GitHub Desktop.
#!/bin/bash
# assign variables
ACTION=${1}
function create_file() {
touch "${1}-54321"
}
function display_help() {
cat << EOF
Usage: ${0} {-c|--create|-h|--help} <filename>
OPTIONS:
-c | --create Create a new file
-h | --help Display the command help
Examples:
Create a new file:
$ ${0} -c foo.txt
Display help:
$ ${0} -h
EOF
}
case "$ACTION" in
-h|--help)
display_help
;;
-c|--create)
create_file "${2:-server}"
;;
*)
echo "Usage ${0} {-c|-h}"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment