I am writing my first ever Shell script today. I think I have found everything I need online but need help on one thing:
I want to be able to pass a couple of optional arguments when the script is called: e.g myscript.sh -filename somefilename -location some/file/location -deleteoption yes
all them 3 options are optional so I need my script at the very first stage to loop through each argument and then depending on the descriptor of the argument (e.g -filename
) store the value (somefilename
) in to the correct variable?
another thing is that the options can be given in any order.
How do I go about achieving this functionality?