[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: tail -f | while read



On Thu, Sep 06, 2001 at 01:23:09PM +0200, Martin F Krafft wrote:
> 
>   tail -f /var/log/syslog | grep something | while read i; do myprog $i; done
> 
> i basically need to run myprog as soon as a new entry in syslog
> happens that matches the criteria of the grep call. it needs to happen
> immediately.
> 

I couldn't get a variation of that working either... but if
myprog is a perl script and is driven by the while(<>) loop,
then you should be able to just pipe the output of the grep
right into it, like so:

   tail -f /var/log/syslog | grep something | myprog

I'm not sure if that can be done directly with a shell
script though.

-- 
John Patton                      patton66@home.com

"Don't ever become a pessimist, Ira; a pessimist is correct
oftener than an optimist, but an optimist has more fun- 
and neither can stop the march of events."
- Robert A. Heinlein - Time Enough For Love



Reply to: