Grep search with multiple strings
search two words in a single line
grep -in "word1.*word2" /var/log/messages
-i to ignore case
search multiple words in a log file front and back
grep -A 2 -B 2 "word1 \| word2 \| word 3"
-A, bring 2 lines above
-B, bring 2 lines below
Eg:
tailf /var/log/messages | grep -A 5 -B 5 "Service Unav\|DENIED\|Temporarily\|conges\|Too many\|Time-out"
you can use tail command to monitor the logs. tailf and tail -f both are same
search two words in a single line
grep -in "word1.*word2" /var/log/messages
-i to ignore case
search multiple words in a log file front and back
grep -A 2 -B 2 "word1 \| word2 \| word 3"
-A, bring 2 lines above
-B, bring 2 lines below
Eg:
tailf /var/log/messages | grep -A 5 -B 5 "Service Unav\|DENIED\|Temporarily\|conges\|Too many\|Time-out"
you can use tail command to monitor the logs. tailf and tail -f both are same
No comments:
Post a Comment