Parse a syslog to get the size
Hi Gurus,
I've a syslog with thousands of entries as listed below. I need to get
the size for each message. I can do this by awk like:
grep "size=" /var/log/syslog | grep "stat=Delivered" | awk '{print
$13}'
but the issue here is, if the mailbox= paramater doesn't a space in it
will work fine but if it does, then awk '{print $13}' fails to grab
the size= parameter.
e.g. - the first line works fine. - mailbox=!users/hubertp/Trash
but the 2nd doesn't.
mailbox=!users/rachels/Junk E-mail - as it has space inbetween the
name.
Any is greatly appreciated.
TIA
Mar 23 03:35:04 mailhost.test.com lmtpd: [ID 583609 mail.notice]
session=1 msgid=<200803231035.m2NAZ1q05926@jelly.test.com>
recipient=<hubertp+Trash@test.com> mailbox=!users/hubertp/Trash
size=1769 uid=449961 stat=Delivered
Mar 23 03:35:04 mailhost.test.com lmtpd: [ID 583609 mail.notice]
session=2 msgid=<000601c88cd9$0789818b$d72c7da3@fbqan>
recipient=<"rachels+Junk E-mail"@test.com> mailbox=!user
s/rachels/Junk E-mail size=3094 uid=3899 stat=Delivered
Mar 23 03:35:05 mailhost.test.com lmtpd: [ID 583609 mail.notice]
session=2 msgid=<200803231035.m2NAZ3uT013941@krb-rwc-m1.test.com>
recipient=<chata+test@test.COM> mailbox=!users/chata/Genie size=1943
uid=398167 stat=Delivered
Mar 23 03:35:06 mailhost.test.com lmtpd: [ID 583609 mail.notice]
session=2 msgid=<200803231035.m2NAZ3uT013941@krb-rwc-m1.test.com>
recipient=<"chrisj+ROOT MAIL"@test.COM> mailbox=!users/chrisj/ROOT
MAIL size=1943 uid=384947 stat=Delivered (linked)
Mar 23 03:35:06 mailhost7.test.com lmtpd: [ID 583609 mail.notice]
session=1 msgid=<200803231035.m2NAZ1q05926@jelly.gene.com>
recipient=<"chrisj+ROOT MAIL"@test.com> mailbox=!users/chrisj/ROOT
MAIL size=1769 uid=384946 stat=Delivered
|