[CentOS] Log File Reviewing

Mon Jan 5 19:03:35 UTC 2009
Bill Campbell <centos at celestial.com>

On Mon, Jan 05, 2009, Joseph L. Casale wrote:
>I need to review a logfile with Sed and cut out all the lines that start with a certain word, problem
>is this word begins after some amount of whitespace and unless I search for whitespace at the
>beginning followed by "word" I may encounter "word" somewhere legitimately hence why
>I don't just search for "word" only...
>
>Anyone know how to make sed accomplish this?

There's always more than one way to do something like this:

sed -n '/^[ \t]*word\s/p' /var/log/messages

pcregrep '^\s*word\b' /var/log/messages

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

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186

It is necessary for the welfare of society that genius should be
privileged to utter sedition, to blaspheme, to outrage good taste, to
corrupt the youthful mind, and generally to scandalize one's uncles.
    -- George Bernard Shaw