Tim Cwik on 15 Dec 2003 17:14:02 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] grep with more structure and multi-line


What about grep -A -B -C? Would that help?


On 2003.12.15 17:04, Jeff Abrahamson wrote:
It happens often enough that I want to grep/awk/whatever files that
have multiline structure.  Today's example is a procmail log file.
Each record is three lines.  Here's an example record:

From plug-announce-admin@lists.phillylinux.org Mon Dec 15 15:31:11 2003
 Subject: plug-announce post from c5dfjjsqoq@lycos.it requires approval
  Folder: /usr/bin/lbdb-fetchaddr					
  3079

If I am searching for things from plug-announce-admin, then I would
want to see the entire three line record presented for each hit.

Of course, it's not too hard to write a little perl script to do this.
But it's not a one-liner, and so it's not as ad hoc as grep, awk, and
so forth on the command line.

Has anyone out there solved this problem so that such things can be
searched in a very ad hoc way?

--
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B


-- Tim Cwik tcwik@stnhbr.com spamtrap: tjc123@stnhbr.com Voice: 609-368-2482 Fax: 609-368-3695 ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug