alissa bader wrote:
> 
> --- srl <[EMAIL PROTECTED]> wrote:
> 
> > what part of the line do you need to grab, other
> > than QAA?
> > got some sample data?
> 
> actually I needed to grab a particular string.  For
> example,  all patterns matching QAA:
> 
> May 11 23:59:57 smtp-out sendmail[7569]: QAA14179:
> to=<[EMAIL PROTECTED]>, delay=
> 07:45:25, xdelay=00:00:01, mailer=esmtp,
> relay=mx1.onmedia.com. [209.133.35.49],
>  stat=Deferred: Illegal seek
> May 11 23:59:56 smtp-out sendmail[7569]: QAA14169:
> to=<[EMAIL PROTECTED]>, delay=
> 07:45:29, xdelay=00:00:01, mailer=esmtp,
> relay=mx1.onmedia.com. [209.133.35.49],
>  stat=Deferred: Illegal seek
> 
> anyway the easiest way to do this (and the way I did
> it before but forgot :>) was to use a "cut" on this
> file. (and someone on this list mailed me about "cut!"
> :>) Since everything I was looking for was in the same
> place on each line.
> 
> thanks again for everyone's help with this!
> 
> --alissa

Try this ...

cat file | grep 'QAA' | sed s/^.*QAA/QAA/ | sed s/:.*$//

That's paraphrased, and I know there is a shorter way of doing it,
but that should get the job done.  Basically, it gets all the lines
with QAA in them, then removes the text either side of the 
QAAnnnnn code.  The "cat file" can be replaced with the actual
output command, if the output is being filtered direct.

You can do just about any filtering with grep, sed, and regular
expressions.

Cut will work also, and probably produces a shorter line.  You can
also replace the 2 sed's with an 'awk', if you know awk syntax ...

grep 'QAA' file | awk '{FS=":"; print $NF-1}'

Also paraphrased, since I'm not near Linux/UNIX at the moment.

Gene Dolgner


_______________________________________________
techtalk mailing list
[EMAIL PROTECTED]
http://www.linux.org.uk/mailman/listinfo/techtalk

Reply via email to