Command line arguments in Bash [duplicate]
Use the getopts
builtin:
here's a tutorial
pages= length= time=while getopts p:l:t: opt; do case $opt in p) pages=$OPTARG ;; l) length=$OPTARG ;; t) time=$OPTARG ;; esacdoneshift $((OPTIND - 1))
shift $((OPTIND - 1))
shifts the command line parameters so that you can access possible arguments to your script, i.e. $1, $2, ...
Something along the lines of
pages=length=time=while test $# -gt 0do case $1 in -p) pages=$2 shift ;; -l) length=$2 shift ;; -t) time=$2 shift ;; *) echo >&2 "Invalid argument: $1" ;; esac shiftdone