Hi,
I am in middle of using some getopt command and am finding some issue. The usage of my script can be like this:
abc.sh <-d | -p |-r> [< -s single_id> | file>] -online < 0 | 1>
The first argument can be either -d or -p or -r. The second argument can be either -s and a id or a file name. So I am stuck up in writing getopts for this.
The below snipper doesn't work.
while getopts "d:p:r:s:o:" param
do
case "$param" in
-d|-p|-r) deviceType=$param
IN_FILE=$OPTARG
statFile $IN_FILE
;;
-s) requested_id=$OPTARG ;;
In this case i am not sure whether the 2nd argument is -s or a file name. that means -d may or may not have an option. How can I write that. In this perhaps -d is always excepting a next argument and breaking.
Please help me.
Thanks in advance.
Sachin