[TriLUG] Learn something new every day.
Jason Tower
jason at cerient.net
Mon Feb 20 16:34:30 EST 2006
you can also combine multiple targets in one command. for example, i
run the following in a screen session on all of my mail servers:
tail -f /var/log/mail/info |grep -v -e pop3d -e imap
the -v is a reverse grep, it returns everything -except- lines that
match the target. i don't care about seeing each user that retreives
their mail via pop or imap, i just want to see smtp messages.
jason
Brian Daniels wrote:
> Maybe this one is common knowledge, but it caught me off guard. And it might
> save somebody some time.
>
> Assume we have a logfile. To watch it on your terminal, you
> could type 'tail -f logfile'.
>
> To filter the output, you could use 'tail -f logfile | grep foo'.
>
> All as expected. But you want more filtering, so you type:
> 'tail -f logfile | grep foo | grep bar'
>
> And get no output at all, even though there are log entries that contain both
> foo and bar!
>
> It turns out that a pipe has a buffer of 4096 characters and is holding the
> data. To make it work, you need:
> 'tail -f logfile | grep --line-buffer foo | grep bar'
> and now you get the filtered output as expected.
>
> --Brian
>
>
More information about the TriLUG
mailing list