This question already has an answer here:
I want to write a bash script which takes different arguments. It should be used like normal linux console programs:
my_bash_script -p 2 -l 5 -t 20
So the value 2 should be saved in a variable called pages and the parameter l should be saved in a variable called length and the value 20 should be saved in a variable time.
What is the best way to do this?
Use the
getopts
builtin:here's a tutorial
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