[HPADM] awk or sed help?

From: Buddy Mills (ramill@wm.edu)
Date: Tue Dec 16 2003 - 10:30:17 EST


I need some help producing a output (file2) from a file (file1). The following is an except from the file. This file is a logfile that avg. about 4 entries per second.

...
<< Loop# 31 Addr# 15 Loc# 532 On-Line * TP# 1 12/16/03 10:02
   VALID
   Tend# 18 (external) amt $1.00 trans amt $1.00 tax $0.00

<< Loop# 1 Addr# 1 Loc# 306 On-Line * TP# 2 12/16/03 10:03
   VALID
   Tend# 1 (internal) ID# 930168453-0 amt $0.01 trans amt $0.01 tax $0.00

<< Loop# 1 Addr# 1 Loc# 306 On-Line * TP# 2 12/16/03 10:03
   VALID
   Tend# 1 (internal) ID# 930135839-0 amt $0.01 trans amt $0.01 tax $0.00
...

I am tail(ing) and grep(ing) for the "930168453" in this file in a "while" statement. When it sees this number it then needs to pull three lines into a file. The line that it grep it found the "930268453" and the two previous line, and only those three line into a file to send to an email.

Example of needed output:
<< Loop# 1 Addr# 1 Loc# 306 On-Line * TP# 2 12/16/03 10:03
   VALID
   Tend# 1 (internal) ID# 930168453-0 amt $0.01 trans amt $0.01 tax $0.00
These three lines may not always be the middle group, they may be at the bottom or top of several scores of these groupings.

I have work out all the parts except how to look at the line I want and pull the previous two lines also. Can anyone help with this?

Many thanks

Buddy Mills
The College of William and Mary
ramill@wm.edu 757.221.2099
http://wmexpress.wm.edu

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:37 EDT