0

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?

0

1 Answer 1

1
#!/bin/bash while [[ ! -z "$1" ]]; do case "$1" in -a) handle_dasha ;; -b) and_so_on ;; esac shift done 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.