For Programmers: Free Programming Magazines  


Home > Archive > AWK > January 2005 > Re: grabbing data from columns









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: grabbing data from columns
Jürgen Kahrs

2005-01-20, 3:56 pm

rudz wrote:
> am new to awk, have been asked to write a shell script to grab columns of
> data from a report,
>
> 1) The report contains a header which i have no use of, i need to trim it
> to get to the actual columns


Use getline to "consume" the header off the file.

> 2) two sample columns on the report looks like this
> Book Value Market Price
> ---------- -------------
> (6,825.51) 1.000 AUD
> 8,363.79 1.000 CAD
> (138.52) 1.000 CAD
> 45,454.08 1.000 GBP
> 68,533.42 1.000 GBP
> (12,675.93) 1.000 GBP


$2 contains the value of the second column.

> can somebody please help and suggest an approach, any help would be
> greatly appreciated, thanks


It is obvious that you posted here before reading
a tutorial. Read any tutorial about AWK and you
should at least have an idea on how to approach
the problem.
Ed Morton

2005-01-20, 3:56 pm



Jürgen Kahrs wrote:
> rudz wrote:
>
>
>
> Use getline to "consume" the header off the file.


No, use "NR<3{next}". getline is rarely necessary.

Ed.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com