[OCLUG-devel] Learning awk/Another Decent Book

Tony Dycks panfisher at earthlink.net
Tue Apr 27 10:33:31 PDT 2004


----- Original Message ----- 
From: "Kevin Brouelette" <kevin1a at varlog.net>
To: <oclug-devel at oclug.org>
Sent: Monday, April 26, 2004 10:32 PM
Subject: Re: [OCLUG-devel] Learning awk


> On Mon, 2004-04-26 at 22:16, Kevin Brouelette wrote:
> > Hello,
> >
> > I'm spending my weeknights this week brushing up on bash shell.
> > The book I'm working with is Addison-Wesley's 'Linux & Unix shell
> > Programing' by David Tansley.
> >
> > Chapter 9 is about 'awk'.
> > After reading the chapter,
> > I thought I would try to use awk to grab the users
> > which their UID from /etc/passwd is greater than 999.
> > [Slackware UIDs start at 1000]
> >
> > So I try this:
> > awk -F: '{if($2 > 999) print$0"\t"$2}' /etc/passwd
> >
> > hoping to print the name, a 'tab', and the UID.
> >
> > It echo's the whole /etc/passwd file and no errors.
> > Am I close or am I off base with trying to do this with awk?
> >
> > TIA
> >
> > Kevin B
>
>
> The obvious strikes. $0 prints the whole line.
>
> awk -F: '{if($3 > 999) print$1"\t"$3}' /etc/passwd
>
> Works.  I have a lot of reading to do. :)
>
> Kevin
>
>
>
Another good reference on Awk is the O'Reilly "Sed & Awk" publication by
Dale Dougherty & Arnold Robbines. Cover price; $29.95 for the 2nd Edition
(might be a newer version out)

Awk is a great shorthand shell language for working with consistent file
structures.


 _______________________________________________
> OCLUG-devel mailing list -- OCLUG-devel at oclug.org
> http://www.oclug.org/mailman/listinfo/oclug-devel



More information about the OCLUG-devel mailing list