tags:

views:

80

answers:

2

When watching a growing log file with e.g. "less -iS +F service.log" I want to limit the display to lines matching a certain pattern.

I tried something like

less +F service.log | grep <pattern> | less +F

which doesn't work. Also

cat < service.log | grep <pattern> | less +F

doesn't do what I want. It looks like the input is already closed and less doesn't show changes.

How can I limit the display to lines matching a certain pattern?

A: 
tail -f service.log | grep <pattern>
Chris May
Thanks for pondering my question though this is not exactly what I want.I want to have "less" functionality, i.e. scrolling, searching, hightlighting within the resulting output.Something like "tail -f service.log | grep <pattern> | less +F" which unfortunalely doesn't do it.
axelrose
A: 

The solution seemed simply

LESSOPEN='|grep <pattern> %s' less +F service.log

but less doesn't continue to read new lines from the growing log file.

axelrose