Hello there,
I'm still working not learning script.
My problem is:
I get a variable from wget like
DATA="Eddy,Murphy,Cork,125,95.41"
String with comma separator
I need to split every fields like
FIRST_NAME="Eddy"
NAME="Murphy"
CITY="Cork"
RUN=125
AVERAGE=95.41
What I learned so far let me think that script is file oriented, but I
would like to use memory variables instead.
I tried to use awk and I wrote
awk -v INPUT=$DATA 'BEGIN { n = split(INPUT, parts, ",")}'
As you can see INPUT passe the string into the "function" by value (I
don't know if it's the good english expression). But is it a real function?
parts is an array with the differents fields. The function works fine.
print parts[1] works fine inside the function.
My problem is I can't find out how to get the array out of the function.
Any idea?
But maybe there is another easier way to do that ????
By the way, what is the usual way to write the variables, functions
etc... names? Capital? Lowercase? other?
Thank you for your help
--
Jean-Pierre
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!