grep with date & unique output

alert.log has the entries with

ORA-XXXX

,

....
Mon Sep 24 15:08:09 2012
WARNING: inbound connection timed out (ORA-3136)
Mon Sep 24 15:08:09 2012
WARNING: inbound connection timed out (ORA-3136)
Mon Sep 24 15:08:09 2012
WARNING: inbound connection timed out (ORA-3136)
Mon Sep 24 15:15:01 2012
Thread 2 advanced to log sequence 17004
  Current log# 8 seq# 17004 mem# 0: /dev/rprod_rdo_015
  Current log# 8 seq# 17004 mem# 1: /dev/rprod_rdo_016
Mon Sep 24 15:15:04 2012
LNS: Standby redo logfile selected for thread 2 sequence 17004 for destination LOG_ARCHIVE_DEST_2
Mon Sep 24 15:15:04 2012
LNS: Standby redo logfile selected for thread 2 sequence 17004 for destination LOG_ARCHIVE_DEST_3
Mon Sep 24 15:30:02 2012
....

If I do

grep ORA-3136 alert.log

, then it just gives,

WARNING: inbound connection timed out (ORA-3136)
WARNING: inbound connection timed out (ORA-3136)
WARNING: inbound connection timed out (ORA-3136)
....

I need to have with the date and time associated with.
The date and time is always right above the error content.

Mon Sep 24 15:08:09 2012
WARNING: inbound connection timed out (ORA-3136)

The same entries can be there more than one. In that case, I need to pull out the unique output so that I can avoid duplicates.

Please advise.

Try this

 egrep  -B 1 ORA-3136 alert.log

I am on AIX 6.1, and getting

egrep: Not a recognized flag: B

Please advise.

See... grep and display few lines before and after Post: 302098992

1 Like

It is an awesome solution!! It works great!