Forum: Ruby on Rails Using grep with tail. Unix challenge!

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-06-05 12:35
I want to tail my development.log file, but i only want to show the
lines that have the word "ERROR" in.  How can i do this??

Doing this :
tail -f development.log | grep "ERROR"
will filter the log file, but it will not constantly update itself. i.e.
newly added lines to the log file that contain "ERROR" are not
displayed.

Does anyone know how to do this?

Thanks
Chris
9d7d8ef2179661d6b30e180fa588cd45?d=identicon&s=25 Calle Dybedahl (Guest)
on 2006-06-05 12:49
(Received via mailing list)
>>>>> "Chris" == Chris  <evilgeenius@gmail.com> writes:

> Doing this :
> tail -f development.log | grep "ERROR"
> will filter the log file, but it will not constantly update itself.

Oh, it does update. It just doesn't show the results to you as often
as you'd like. The problem is that grep will use its normal I/O
buffers, which are suited for reading from and writing to files. If
you're using GNU or FreeBSD grep, try giving the --line-buffered
option to it.
--
		     Calle Dybedahl <calle@cyberpomo.com>
		 http://www.livejournal.com/users/cdybedahl/
              Please pay no attention to the panda in the fridge.
Cd8c9864d88bcafc164d8fdb820cc451?d=identicon&s=25 Chris (Guest)
on 2006-06-05 13:20
Yeah that works,
thanks
Chris
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2006-06-05 17:36
(Received via mailing list)
On Jun 5, 2006, at 6:47 AM, Calle Dybedahl wrote:

> option to it.
> --
> 		     Calle Dybedahl <calle@cyberpomo.com>
> 		 http://www.livejournal.com/users/cdybedahl/
>               Please pay no attention to the panda in the fridge.
> _______________________________________________

If you have 'less', you can do:

less -p'ERROR' development.log

and use the 'F' command to follow the end like 'tail -f' does.  This
has the added benefit of being able to break out of the 'Waiting...'
and peruse the log for a bit before continuing with another 'F'.

-Rob

Rob Biedenharn		http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
+1 513-295-4739
This topic is locked and can not be replied to.