Skip to content

Simple CLI argument parsing template for a stand alone bash script

License

Notifications You must be signed in to change notification settings

mattbryson/bash-arg-parse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Bash Arg Parse Example

A simple bash script that can parse named, short and positional CLI arguments.

This is to be used as a template for simple bash scripts that accept various CLI arguments.

Usage

Use arg_parse_example as the basis of a bash cli script.

To run the example...

$ ./arg_parse_example -h
usage: arg_parse_example -a AN_ARG -s SOME_MORE_ARGS [-y YET_MORE_ARGS || -h]

  -a | --an_arg            : A super special argument
  -s | --some_more_args    : Another argument
  -y | --yet_more_args     : An optional argument
  -h | --help              : This message
$ ./arg_parse_example -a foo --some_more_args bar one two
you passed in...

positional arg 1: one
positional arg 2: two
named arg: an_arg: foo
named arg: some_more_args: bar
named arg: yet_more_args: a default value

About

Simple CLI argument parsing template for a stand alone bash script

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages