[plug] Text Filtering

Leon Brooks leon at brooks.fdns.net
Tue Mar 19 17:15:53 WST 2002


On Tuesday 19 March 2002 16:43, Andrew Barbara wrote:
> Thanks for that it works great!
> Can you tell us how the gawk command works?

Er, it works very quickly? (-:

> >    gawk '{ print $9 }'

'...'       is to keep the argument as one word (and preserve the $9
            unmolested)

{ ... }     is a code block; the lack of any prefix says ``apply this to
            every line'' - if, for example, you only wanted to do lines
            ending with .rpm, you would say /\.rpm$/ { ... } instead, or
            lines belonging to fred get selected by $3 == "fred" { ... }

print $9    prints the 9th argument on each line, separated by
            whitespace as a default

(G)awk is a long way from being the most wonderful command-line filter. 
Matt...? Matt...? (-:

Cheers; Leon



More information about the plug mailing list