Jan 31, 2012
tom

shell script + match MAJOR and CRITICAL strings from log file

Question

I need to match lines that have MAJOR and CRITICAL strings

that comes after the word ERROR:< any integer number >

please advice how to do that with one awk or sed command?

  more HW_Log.txt CHK_HW             ERROR:0  INFO         self_monitor     Verifying HW machine 
 CHK_HW             ERROR:1  MAJOR        self_monitor     Verifying HW machine 
 CHK_HW             ERROR:1  CRITICAL     self_monitor     Verifying HW machine 
Asked by Eytan

Answer

This can be done using grep like:

$ grep "ERROR:[0-9]*  (CRITICAL|MAJOR)" /path/to/file
Answered by Khaled

Related posts:

  1. How to fetch lines between two strings using shell script?
  2. Shell script to extract string from a file and return the next chars until a whitespace
  3. Shell Script: How do I turn “virsh list | grep MediaWiki” into an if condition?
  4. Shell Script for Sending output or log via email
  5. Shell script file name format

Leave a comment