[OCLUG-devel] Learning awk
Kevin Brouelette
kevin1a at varlog.net
Mon Apr 26 22:32:38 PDT 2004
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
More information about the OCLUG-devel
mailing list