Rama
Rama

Reputation: 875

Unix command for searching multiple keywords

Need to check in the error log on UNIX server for multiple sites, ex. lets say there are 3 sites ABC.com, XYZ.com and OPQ.com. i want to get error log from server for any of these sites lies.

I tried with

tail -99999  /apache/log/error_log| grep 'ABC | XYZ | OPQ'

But was not working..

Upvotes: 1

Views: 470

Answers (3)

Jotne
Jotne

Reputation: 41446

Using awk

tail -99999  /apache/log/error_log | awk '/ABC|XYZ|OPQ/'

Upvotes: 1

Rahul R Dhobi
Rahul R Dhobi

Reputation: 5806

tail -99999  /apache/log/error_log| grep -E '(ABC|XYZ|OPQ)'

or

tail -99999  /apache/log/error_log| grep -e ABC -e XYZ -e OPQ

Upvotes: 3

vdudouyt
vdudouyt

Reputation: 936

Just use egrep:

tail -99999  /apache/log/error_log| egrep '(ABC|XYZ|OPQ)'

Upvotes: 1

Related Questions