Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering on log file 2

Status
Not open for further replies.

dklloyd

MIS
Mar 9, 2001
78
0
0
GB
Sorry, I should have explained more explain more on my previous thread.

Every time a record is inserted into the log a Date is entered 1st followed by a line(s) detailing the change.

Some of the less interesting things I don't want to see (including the date that went with the item).

In brief what I want it to convert the following:

Tue Aug 20 08:02:18 2002
Boring data
Tue Aug 20 08:02:18 2002
Boring data
Tue Aug 20 09:00:04 2002
Good data 1
Good data 2
Tue Aug 20 09:00:09 2002
Good data 3
Tue Aug 20 09:00:21 2002
Boring data
Boring data
Tue Aug 20 09:00:23 2002
Good data 4

Into:
Tue Aug 20 09:00:04 2002
Good data 1
Good data 2
Tue Aug 20 09:00:09 2002
Good data 3
Tue Aug 20 09:00:23 2002
Good data 4

The number of lines of data lines between dates can vary. I presume I will have to check for colons on the 14th & 17th column to identify a date?

Thanks again

dklloyd
 
You need to identify something in the date line which will never occur in any other line, like the fact that it begins with the day of the week or, as you suggest, has colons in columns 14 and 17. Here is a solution using the day of the week.
Code:
{
  if ($1 ~ /(Sun)|(Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)/) {
    a = $0
  }
  else {
    if ($0 !~ /(Boring data 1)|(Boring data 2)/) {
      if (length(a) > 0) {
        print a
        a = ""
      }
      print
    }
  }
}
CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top