Re: Log File Reviewing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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@xxxxxxxxxxxxx  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
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux