Can some one tell me how to parse the following command line options with getopt?
myCmd [[-f <file> | -k | -v] -e <env> -h help]
where
f, k and v are mutually exclusive. f and e both need a parameter, but k and v do not.
So the command can be:
- mycmd -f file -e aaa or
- mycmd -v -e aaa or
- mycmd -k -e aaa
I have tried the following:
while getopts "f:kve:" o
do
case "$o" in
f | k | v) process_file ;;
k) process_key ;;
v) process_var ;;
e) process_env ;;
*) print_help ;;
esac
done;
That does not seem to work. Any help is appreciated.