Paragraph-option to grep
I've got a huge logfile (~5mill lines) in text format which is actually a maillog. The log is formatted like this:
----- New message date time ----- From: someone@example.com Sender: someone@example.com Replay: someone@example.com To: someoneelse@example.org CC: BCC: Subject: Example Mail id: 12345 Mail name: /tmp/mail_12345.eml --------------------------------------- Every entry is inserted like the example above. In AIX, the grep-command has a option "-p" which allows you to select a delimiter for a paragraph (here: -----), so when grep finds something, everything between the delimiters are printed out. I'm searching through tons of mail, but only want to get the output with selected words. Is there a similar possibility in Linux? Either a different option to grep (which I haven't found), or a standalone script / program.. Does anyone know? |
Hi,
Using awk: awk '{ FS="\n" ; RS="-----" } /12345/ { print }' infile Or as a shellscript: Code:
#!/bin/bash Hope this helps. |
Thanks a lot! :) This was exactly what I was looking for!
|
All times are GMT -5. The time now is 10:56 AM. |