[CentOS] Log File Reviewing

Spiro Harvey spiro at knossos.net.nz
Mon Jan 5 19:23:22 UTC 2009


> awk '$1 == "word"{print}' /var/log/messages

This example assumes that word is the first field and that it consists
only of "word". If the first field is "word1" this won't match.

Fixes for this are 

awk '$1 ~ "word"{print}'

(this matches any occurrance of "word" in the first field)

or:

awk '/^[[:space:]]*word/ {print}'

(this matches any line starting with whitespace followed immediately by
"word")


-- 
Spiro Harvey                  Knossos Networks Ltd
021-295-1923                    www.knossos.net.nz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.centos.org/pipermail/centos/attachments/20090106/fb591e36/attachment.bin 


More information about the CentOS mailing list