tags:

views:

26

answers:

2

I'm trying to make a getopt command such that when I pass the "-ab" parameter to a script, that script will treat -ab as a single parameter.

#!/bin/sh
args=`getopt "ab":fc:d $*`
set -- $args
for i in $args
do
case "$i" in
        -ab) shift;echo "You typed ab $1.";shift;;
        -c) shift;echo "You typed a c $1";shift;;
esac
done

However, this does not seem to work. Can anyone offer any assistance?

A: 

getopt supports long format. You can search SO for such examples. See here, for example and here

ghostdog74
Can you please offer an example of how this is used?
Waffles
+1  A: 

getopt doesn't support what you are looking for. You can either use single-letter (-a) or long options (--long). Something like -ab is treated the same way as -a b: as option a with argument b. Note that long options are prefixed by two dashes.

paprika