I have wrote simple shell script test.sh
as follows:
while getopts ":A:" OPTION
do
case $OPTION in
A)
echo $OPTARG
?)
echo "no option"
esac
done
And executed the scripts as follows
$ ./test.sh -A 1 2
Now if got argument 1 by $OPTARG but how can i access the second argument ( 2 in this case)?
Regards Jayesh
There are several options.
(1) You can use
shift
and take$1
(2) You can iterate through the args:
There are other alternatives also.