[HPADM] Re: awk or sed help?

From: Buddy Mills (ramill@wm.edu)
Date: Tue Dec 16 2003 - 14:05:49 EST


Thanks to the following persons for their reply

Chris Medaglia
Kevin Nikiforuk
Nuno Vitoria
Mark Schupsky
David Totsch
Bertrand Hutin

The following "cut and paste" solutions were returned. Thanks to all.

1) awk 'BEGIN {RS="<<"} /930168453/ {print}' data_file

2) awk 'BEGIN{ FS = "\n" ; RS = "" } $3 ~ /930168453/ {print $0}' file1 >
file2

3) awk BEGIN {RS="" FS="\n"} $3 ~ /930168453/{print $1"\n"$2"\n"$3 |
"mailx -s subject root"}

> --- Buddy Mills <ramill@wm.edu> a écrit : > 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