bash getopts example

while getopts ":c:sd" Option
# Initial declaration.
# c, s, and d are the flags expected.
# The : after flag 'c' shows it will have an option passed with it.
case $Option in
# w ) CMD=$OPTARG; FILENAME="PIMSLogList.txt"; TARGET="logfiles"; ;;
s ) PORT=20 ;;
d ) DEBUG=true ;;
c ) CMD=$OPTARG ;;
* ) echo "Not recognized argument"; exit -1 ;;
shift $(($OPTIND - 1))


The Shift said…
AWESOME!! thanks a bunch man. the fact that you took time to explain the code with comments was a huge help!! if i could i'd give you a high five

Popular posts from this blog

Vim vi how to reload a file your editing