Afficher un message
Vieux 24/03/2008, 20h43   #3
pk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Parse a syslog to get the size

explor wrote:

> 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.


A possible solution:

awk '/size=/ && /stat=Delivered/ {match($0,/size=[[:digit:]]+/); print
substr($0,RSTART,RLENGTH)}' /var/log/syslog

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
  Réponse avec citation
 
Page generated in 0,05410 seconds with 9 queries