Using Flags and Arguments in Bash
Here’s a simple example script, showing how to deal with different inputs depending on the flag preceding them: #!/bin/bash USAGE=”Usage: Enter a noun after either -p (polite) or -i (insulting).” while getopts “:p:i:” OPTIONS; do case $OPTIONS in p ) polite=$OPTARG;; i ) insulting=$OPTARG;; h ) echo $USAGE;; \? ) echo $USAGE exit 1;; * […]