Friday, 2 November 2012

Grep:Search Multiple Words Using grep Command


Using grep Command


In this example, search warning, error, and critical words in a text log file called /var/log/messages, enter:

[root@new-host sankar]# cat /var/log/messages |grep error
Oct 31 15:52:32 new-host kernel: usb 1-1: device not accepting address 5, error -71

[root@new-host sankar]# grep 'warning\|error\|critical' /var/log/messages
Oct 31 15:52:32 new-host kernel: usb 1-1: device not accepting address 5, error -71
[root@new-host sankar]#

To just match words, add -w swith:

No comments:

Post a Comment