satch_boogie satch_boogie - 2 years ago 53
Python Question

extract the lines from file with bash or python

Here is my file content which is output of pflogsumm

Host/Domain Summary: Messages Received
msg cnt bytes host/domain
-------- ------- -----------
415 5416k
13 19072 xyz.localdomain

Senders by message count
13 root@jelly.localdomain

Recipients by message count
506 <= Extracter from here to ...
13 <= Extract ends here

Senders by message size

The output seems to have the information feilds separated by "title" and a "new line". For example
Recipients by message count ...<contents of interest> ... NewLine

I tried with below sed expression but it returns all lines after matching the string
"Recipients by message count"

sed -nr '/.*Recipients by message count/,/\n/ p'

Desired output: All emails under
"Recipients by message count"

Answer Source

Using awk:

awk '/Recipients by message count/{p=1}!$0{p=0}p' input_file

Will print the Recipients by message count block

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download