I want to parse some arguments to a bash script using getopts but want to be able to access the remaining args that are not included in the option list. So for example, if I have a call:
% script -a -b param -c param -d other arguments here
I would have:
while getopts "ab:c:d" opt ; do
.
done
What is the easiest way to get "other arguments here", which should be unprocessed by getopts?
you need to shift when you parse an arg, or put
shift $((OPTIND -1)) after you have finished parsing, then deal in the usual way e.g.
At the end of the parsing, once you have shifted the variable $@ contains the end of the line :