Re: Collect errors from a file
From: Juhan Leemet (juhan_at_logicognosis.com)
Date: 11/09/04
- Next message: KKramsch: "Re: $1/*/ vs ${1:+"${1%/}"/}*/"
- Previous message: Stephane CHAZELAS: "Re: Problem using grep through the unix shell: doesn't accept a regular expression in filename"
- In reply to: Dale DeRemer: "Collect errors from a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 09 Nov 2004 19:17:17 -0300
On Mon, 08 Nov 2004 11:10:16 -0500, Dale DeRemer wrote:
> I run a job that dumps errors from our application into to a comma separated
> file.
> I want to read the 5th field of this file and write the entire line to
> another file if it contains a specified value.
> I know awk -F[,] '{print $5}' file.csv > result.txt
> Will send the 5th field to another file. What I really need is to find and
> send the entire line to another file if $5 = 1.
> Any ideas?
You need a pattern to be matched in there, like:
awk -F, '$5==1 {print}' file.csv >result.txt
The Solaris man page for awk has some words about
pattern { action }
The Linux man page has similar words.
BTW, there is a comp.lang.awk newsgroup specifically for awk stuff.
p.s. First go around, I made the typical newbie typo $5=1 which ended up
printing all lines with 5th field as 1. Don't make that mistake.
-- Juhan Leemet Logicognosis, Inc.
- Next message: KKramsch: "Re: $1/*/ vs ${1:+"${1%/}"/}*/"
- Previous message: Stephane CHAZELAS: "Re: Problem using grep through the unix shell: doesn't accept a regular expression in filename"
- In reply to: Dale DeRemer: "Collect errors from a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|