I want to be able to search through passed arguments before my code executes, and allocate the different variable names depending on the type of input it is (e.g. file).
My program works if I type:
./program input.txt -a
But when I type:
./program -a input.txt
My program fails.
It fails because my first line of code is:
FILE=$1
And -a
is not a file, so how can I 'skip' this, and move onto the next passed argument and check if it's a file?
Any help is appreciated, thank you in advance. :)