How I can pass both an optional flag and unrelated required parameter to a bash script?
Example, a user can type in:
Code:
./myscript.sh -f myname
or just:
Code:
./myscript.sh myname
I can use getopts to find -f was set, but that sets $1 to "-f" rather than setting it to myname.
I can make $2 myname, but since the -f is optional, that will be $1 sometimes and there won't be a $2.
What is the best way to do this?
TIA