I have this code, and when I call it in command line, it shows the echo in option/the one I have in each option/ but $OPTARG is undefined. And I have no idea why.
OPTIND=1 optm= optl= while getopts "ml:" opt do case "$opt" in m) optm=$OPTARG echo "m was triggered" ;; l) moznostl=$OPTARG echo "l was triggered" ;; esac done shift "$((OPTIND-1))"
and my second question is:
can this be used to start with second argument? I mean it works but wheater it is legit way to do that. for example:
./project first -l second
so it would skip the first agument and started with -l?