Article 53JYJ [SOLVED] Bash script passing variable and values

[SOLVED] Bash script passing variable and values

by
GPGAgent
from LinuxQuestions.org on (#53JYJ)
I know I can use getopts to provide options and values to a script
Code:makereport -u jsmith -p notebooks -d 10-20-2011 -f pdfand in the script you do this:
Code:while getopts u:d:p:f: option
do
case "${option}"
in
u) USER=${OPTARG};;
d) DATE=${OPTARG};;
p) PRODUCT=${OPTARG};;
f) FORMAT=${OPTARG};;
esac
doneWhat I would like to do is this:
Code:makereport USER=jsmith PRODUCT="note books" DATE=10-20-2011 FORMAT=pdfand then in the script I have immediate access to the variables, for example, in the script:
Code:echo "User: $USER | Product: $PRODUCT"Would produce:
Code:User: jsmith | Product: note booksAlso I would like the order of the parameters to not matter.

I'm think I'll need to test $1, $2, $3 etc and go from there.

Any clever methods out there?latest?d=yIl2AUoC8zA latest?i=oyQGXqP073g:Nq8jcnUhB0E:F7zBnMy latest?i=oyQGXqP073g:Nq8jcnUhB0E:V_sGLiP latest?d=qj6IDK7rITs latest?i=oyQGXqP073g:Nq8jcnUhB0E:gIN9vFwoyQGXqP073g
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments