7

I need to write a bash script, and would like it to parse unordered parameters of the format:

scriptname --param1 <string> --param2 <string> --param3 <date>

Is there a simple way to accomplish this, or am I pretty much stuck with $1, $2, $3?

edit

(note - I don't need long parameter names - single letters would be fine too)

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
Brent
  • 22,857
  • 19
  • 70
  • 102

1 Answers1

10

You should use getopt.

pjz
  • 10,595
  • 1
  • 32
  • 40
  • Thanks - That put me on the right track - I think that I actually want getopts - as it is apparently simpler, and I don't need the long names – Brent May 06 '09 at 03:15
  • Cool, but you need to fix your question then :) It specifically lists long param names in the example. – pjz May 06 '09 at 03:21