#! /usr/bin/ksh
while getopts a: b: ab:f: VAR
do
case $VAR in
a) A=${OPTARG}
echo $A;;
b) B=${OPTARG}
echo $B;;
ab) AB=${OPTARG}
echo $AB ;;
f) F=${OPTARG}
echo $F ;;
esac
done
When I execute sh a.ksh -a 1 -b 2 -ab 3 -f 4 as below and displays
1
2
b
Instead of as below
1
2
3
4
As I understand a,b's are repetitive that is the reason it is not working if there is a way to make it work please let me know.
I want to thank you purdym and anurag.singh for reply.
As I said it is more like repetitive option issue. For example if do as below it is working fine.
#! /usr/bin/ksh
while getopts a: b: cd:f: VAR
do
case $VAR in
a) A=${OPTARG}
echo $A;;
b) B=${OPTARG}
echo $B;;
c) RESET_IF_REQUIRED=1 ;;
d) DSSERVER=${OPTARG}
echo "3" ;;
f) F=${OPTARG}
echo $F ;;
esac
done
echo "Final"
Execute
$ sh a.ksh -a 1 -b 2 -cd 3 -f 4
1
2
3
4
Final
I hope there is way to do it but I am not that good with UNIX.