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 out a log file

Status
Not open for further replies.

dklloyd

MIS
Mar 9, 2001
78
0
0
GB
Hi
I have a log file that I just want the interesting stuff out of each day.

Each record starts with a Date and may be on two or more lines.

How can I filter out the sections that include 'Current log#' and 'media recovery disabled', but keep the other sections. The output will go to a new file.

I haven't had to do any awk work before (got away with it till now!) and I can see there's a potential number of different methods, but Im keep getting stumped on the various options.

The log file looks like:

Tue Aug 20 08:02:18 2002
Thread 1 advanced to log sequence 14581
Tue Aug 20 08:02:18 2002
ARC0: media recovery disabled
Tue Aug 20 08:02:18 2002
Current log# 1 seq# 14581 mem# 0: /log_area/LOG1A.RDO
Current log# 1 seq# 14581 mem# 1: /log_area/LOG1B.RDO
Tue Aug 20 08:12:53 2002
ARC0: media recovery disabled
Tue Aug 20 08:12:53 2002
Thread 1 advanced to log sequence 14582
Current log# 2 seq# 14582 mem# 0: /log_area/LOG2A.RDO
Current log# 2 seq# 14582 mem# 1: /log_area/LOG2B.RDO
Tue Aug 20 09:00:03 2002
alter database datafile '/u11/IDX02.dbf' resize 710m
Tue Aug 20 09:00:04 2002
Completed: alter database datafile '/u11/oradata/CMBM/CMBM_ID
Tue Aug 20 09:00:09 2002
alter database datafile '/u11/IDX02.dbf' resize 720m
Completed: alter database datafile '/u11/oradata/CMBM/CMBM_ID
Tue Aug 20 09:00:21 2002
alter database datafile '/u11/IDX02.dbf' resize 730m
Tue Aug 20 09:00:23 2002
Tue Aug 20 09:00:23 2002
ORA-1237 signalled during: alter database datafile '/u11/ID.
Tue Aug 20 09:00:29 2002
alter database datafile '/u11/IDX02.dbf' resize 725m
Completed: alter database datafile '/u11/CMBM_ID

Any help would be appreciated.

dklloyd
 
nawk '$0 !~ /(Current log#)|(media recovery disabled)/' myLogFile.txt vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
I'm not sure what you mean by &quot;sections&quot; here..i think it is a little more complicated than what I'm seeing at first glance.

According to your description this should work:
awk ' {
if ($0 !~ /Current log/ && $0 !~ /media recovery/) {
print $0 > &quot;mylogfile&quot;
}
}' logfile
 
Sorry guys - should explain more.

What I want to see is:

Tue Aug 20 08:02:18 2002
Thread 1 advanced to log sequence 14581
Tue Aug 20 08:02:18 2002
alter database datafile '/u11/IDX02.dbf' resize 710m
Tue Aug 20 09:00:04 2002
Completed: alter database datafile '/u11/oradata/CMBM/CMBM_ID
Tue Aug 20 09:00:09 2002
alter database datafile '/u11/IDX02.dbf' resize 720m
Completed: alter database datafile '/u11/oradata/CMBM/CMBM_ID
Tue Aug 20 09:00:21 2002
alter database datafile '/u11/IDX02.dbf' resize 730m
Tue Aug 20 09:00:23 2002
Tue Aug 20 09:00:23 2002
ORA-1237 signalled during: alter database datafile '/u11/ID.
Tue Aug 20 09:00:29 2002
alter database datafile '/u11/IDX02.dbf' resize 725m
Completed: alter database datafile '/u11/CMBM_ID

so I need the line that precedes it with the Date & time which states the time the action was done (what I referred to as section).

Thanks again

dklloyd

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top