This question already has an answer here:
I am new to shell script and I had the following situation. I have a perl script that has multiple options. Not all the options are required.
example.prl [options] options: -h help -o filename output file name -f force output file overwrite -d debug mode ...
I want to create a shell script to parse the options to the prl script. And the options are not all required, for instance:
./example.sh -o output_file OR ./example.sh -o output_file -f
Here is some of my progress but only work with 1 argument:
#!/bin/bash path=/proj/scripts/example.prl option=$1 option_value=$2 echo "The command to run:" echo $path $name $option $path $option $option_value
Is there a way to loop through all of the options user put and construct the command?