# Using grep with tail. Unix challenge!

**URL:** <https://www.ruby-forum.com/t/using-grep-with-tail-unix-challenge/62478>\
**Category:** Rails\
**Created:** [June 5, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/using-grep-with-tail-unix-challenge/62478 "2006-06-05T12:35:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 5, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/using-grep-with-tail-unix-challenge/62478/1 "2006-06-05T12:35:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 5, 2006, 12:49pm UTC](https://www.ruby-forum.com/t/using-grep-with-tail-unix-challenge/62478/2 "2006-06-05T12:49:47Z")

</div>

> > > > > “Chris” == Chris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 D. <removed_email_address@domain.invalid>
	 http://www.livejournal.com/users/cdybedahl/
          Please pay no attention to the panda in the fridge.

```

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 5, 2006, 1:20pm UTC](https://www.ruby-forum.com/t/using-grep-with-tail-unix-challenge/62478/3 "2006-06-05T13:20:52Z")

</div>

Yeah that works,  
thanks  
Chris

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [June 5, 2006, 5:36pm UTC](https://www.ruby-forum.com/t/using-grep-with-tail-unix-challenge/62478/4 "2006-06-05T17:36:14Z")

</div>

On Jun 5, 2006, at 6:47 AM, Calle D. wrote:

> ## option to it.
> 
> ```
> Calle D. <removed_email_address@domain.invalid>
> 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 B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid  
+1 513-295-4739
