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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pull multiple lines with AWK

Status
Not open for further replies.

squash

MIS
May 21, 2001
99
US
Ok,
I have been reading my sed and awk books and still am no closer, hopefully one of you can help.
I have a log file with over 6,000 lines in it.
I need to get a time stamp for a specific error in this file.
If I grep on the error “SQL0911N” I get the following line

][DB2/SUN] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Reason code "68". SQLSTATE=40001

However the Time stamp is several lines down as you will see in the block of text below.


I figure I need Awk for this but it’s getting fuzzy.

Thankx in advance for your help
Doug




com.ibm.ejs.persistence.EJSPersistenceException: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver
][DB2/SUN] SQL0911N The current transaction has been rolled back because of a deadlock or timeout. Rea
son code "68". SQLSTATE=40001
; nested exception is:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/SUN] SQL0911N The current transaction has
been rolled back because of a deadlock or timeout. Reason code "68". SQLSTATE=40001
-- 15:08:15,04/25/2003
 
This awk script is not tested and assumes that the time stamp will be the next line atrating with " --"

/SQL0911N/{print;flg=1}
flg && /^ --/{print;flg=0}


CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
considering the lines u have given, assuming that this will be the maximum fields of error logged, the time stamp is entered as 26th field.

so try using this,

cat logfile | grep "SQL0911N" | awk '{print $26}'

let me know if it worked.

~Ramu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top