How can I get remaining args after pulling out parsed items using 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.
while getopts "ab:c:d" opt ; do
.
done
shift $(expr $OPTIND - 1 )
while test $# -gt 0; do
echo $1
shift
done