My question is about a script I was asked to write for college so it's H/W, but I am stuck and haven't figured out a solution.
I am trying to get the arguments of
./tool.sh -f persons.dat -id <id>
because I want the in order to display the data of the person.
tool.sh
is my program and persons.dat
is a file with data of people that looks like this
3601|Wang|Lin|male|1981-01-02|2010-03-14T19:06:18.373+0000|1.10.108.68|Firefox
id|lastName|firstName|gender|birthday|creationDate|locationIP|browserUsed
I know I can't use getopts beacause id is a two letter flag and I could pass it manually but I am asked not to take the position in consideration so:
./tool.sh -f persons.dat -id <id>
and:
./tool.sh -id <id> -f persons.dat
should be of the same use
Any ideas?
case
to parse the options, but you're probably doing it in some different way.-id
would generally mean the same as-i -d
. Making it-id
understood as a single option would confuse your users especially if you also accept single-letter options.