I've a script where I can pass different set of arguments for the work the script has to do. The options are specified below:
[Show Help] ./myscript.sh -h
[To Create] ./myscript.sh -c -f /input_loc/input_file.txt
[To Export] ./myscript.sh -e -d /destination_loc/exported_db_date.csv
[To Import] ./myscript.sh -i -s /source_loc/to_import_date.csv
And the script myscript.sh
has getopts
to parse the options and then push it to case - esac
to apply checks and logics for each of the arguments passed to check their validity. For example, like below:
while getopts "cd:ef:his:" o; do
case "${o}" in
Put options and their check logics
esac
done
My question is, what logic can I use to force arguments to be presented in particular sets only, for e.g.
Allowed Option set
./myscript.sh -h
./myscript.sh -c -f <file_name>
./myscript.sh -e -d <file_name>
./myscript.sh -i -s <file_name>
NOT Allowed Option set
./myscript.sh -h -c -f <file_name>
./myscript.sh -h -d <file_name>
./myscript.sh -e -s <file_name>
./myscript.sh -c -i -f <file_name>