by Jonathan Simms on Tue Dec 02, 2008 1:45 pm
Hi Mary,
awk, as it is generically called, is a scripting language developed by Aho, Weinberger, and Kernighan.
awk -F: '$3 > 499' '{ print $1 }' /etc/passwd
-F: is telling awk to use the colon character as a field delimiter.
'$3 > 499' This is essentially saying take the third field and see if it's greater than 499. It is using the colon character for parsing here. Looking at /etc/passwd we can see that the field we wish to use in this evaluation is the third one over, which is the UID or user id. The UID field being the third field is $3.
Accordingly $0 would print the whole line, $1 prints the username, $2 the x for passwd, $3 UID etc.
'{ print $1 }' is saying if there are UIDs greater than 499 print the first field, which is $1, which is the username.
/etc/passwd is the file we are examining.
Hope that helps.
Jonathan