bash help setting variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to write a bash script which makes an inquiry to an http
service that replies with a series of keyword=value plain text data,
one pair per line.
I want to extract only a few of the lines, and make variables of them
available to rest of my bash script.

I have this so far, and it works fine in terms of selecting the
correct data items... but how can I get them into $1 $2, or other
symbolic names?

wget -O - http://.../cgi-bin/dirent?ntid=$MYVAR \
        | egrep '^(LastName)|(FirstName)|(Email)=' \
        | sort \
        | sed s/.*=//

The idea of sorting was because I was anticipating putting the results
in an array, then I'd know array[0] is email... etc

I also tried using sed to convert those lines into assignment
statements and piping that to eval... nope

This sort of thing must be pretty common, but I'm just missing
something fundamental.

I tried setting variable like this:
myarray=$( <all that stuff above> )

but that just created a variable with all the item including their \n
characters...
I'm ALMOST there... I just have to add some sed stuff to escape
quotes, and wrap quotes so I can use the pieces in other commands.
But what's giving me trouble is how to get the individual parts into
individual vars, or array elements.

Any assistance is appreciated.

Thanks

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux