scripting help

From: David Sharples (david.sharples3@ntlworld.com)
Date: 04/08/03


From: "David Sharples" <david.sharples3@ntlworld.com>
Date: Tue, 8 Apr 2003 21:48:21 +0100

Hi, I have this one line which pull field 32 and 170 out of a csv file and
then awks through them to keep the last occurence of field 32.

However sometimes field 32 is blank so I dont want to output that combo to
my new file, can I in the cut part only take fields that actually have a
value in them or how would i do it in the awk part?

Thanks

cut -f 32,170 -d "," s006.txt | awk '{arr[$1]=$0} END{ for(i in arr){print
arr[i]}}' > dave.txt.

Also is the awk part 'efficient' can I speed it up anyway?



Relevant Pages

  • A new project with awk
    ... I have a CSV file with a dump of records from a table in one of our ... The first problem that I was finding was that awk is complaining that the ... The first line of the CSV file is the header information for each column, ... and grep for it in several hundred archived files. ...
    (comp.lang.awk)
  • Re: searching and extracting fields within a field
    ... The short answer is that awk is not well suited for that requirement. ... Awks builtin field separation is far too simple to handle this; ... Brian Kernighan's short book "The Awk Programming Language" ... That said, if your CSV file really _is_ CSV, then it ...
    (comp.unix.shell)
  • Re: A new project with awk
    ... We are running HP-UX 11i, and unfortunately, I don't know nor know how to determine the version of awk I'm using. ... In this CSV file, there is a specific column that I need to take the data from using a ERE to pick out the fields that are actually useful. ... and grep for it in several hundred archived files. ... for (pat in pats) ...
    (comp.lang.awk)
  • Re: speed up with grep.
    ... david huan wrote: ... I have to sort out the ... is this possible to use awk. ... $TMP is used to save one row in csv file, but how can i attach the ...
    (comp.unix.shell)
  • Re: Extract a field in a string collection
    ... From a .csv file, I want to extract the last field (say it's $15, or, I ... the AWK will sent the values to. ... None of this keeps the comma separator. ... scott@thinkpad:~> cat foo.awk ...
    (comp.lang.awk)