grep active log file

Hi Gurus,

I am facing a problem with grepping a set of data in active log file which are the info not in uniform, below is the sample data information.
I am trying to grep value.

  • Connect_PM Connect to APPS gateway failed
  • ERROR connection to host anyserver.com, service 6600 timed out
  • ERROR connection to partner broken

the problem that i facing now is, the set of info are active and not uniform, to make a reference, i am thinking to grepping the last update "TIMESET" and follow by the line of the row of information, how do i perform it using shell? Thanks

>TIMESET> Tue Jul 15 05:25:49 2008
T:6 ======> Connect to APPS gateway failed
Connect_PM  DEST=TAH, GWHOST=anyserver.com, GWSERV=anyNameSrvr, ASHOST=anyserver.com, SYSNR=00

LOCATION    CPIC (TCP/IP) on local host with Unicode
ERROR       connection to host anyserver.com, service 6600 timed
            out

TIME        Tue Jul 15 05:25:49 2008
RELEASE     640
COMPONENT   NI (network interface)
VERSION     37
RC          -12
MODULE      nixxi_r_mt.cpp
LINE        1067
DETAIL      NiPConnect
COUNTER     46

I don't understand what you are trying to achieve. What is your desired output?

Maybe my question are not clear, sorry for that.
My desire output are like below:

And it should content the current error from the log files.
Output:-

>
Tue Jul 15 05:25:49 2008 ERROR connection to host anyserver.com, service 6600 timed out

Still I am not very clear about the requirement.
Also, I could not see the third error message "ERROR connection to partner broken" in your logs.

as par my assumption, if you want to grep on the basis of "TIMESET" then one alternative could be "To grep the lines till your Error message".

grep -A5 ">TIMESET> Tue Jul 15 05:25:49 2008"

will show you the next five lines just after the "TIMESET".

if you want to achieve something else, please let us know clearly.

Hrm, you could use awk or perl:

awk '/^>TIMESET>/ { $1=""; ts=$0; error=1 } error && /^ERROR/ { print ts,$0; error=0; }'