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

Re: [OFF-TOPIC] less with built-in grep ?



On 11 Mar 1998, Lorens Kockum wrote:

> In debian-user,  Ben Pfaff <pfaffben@pilot.msu.edu> wrote:
> >   With the example above, I suppose I could write some kind of macro,
> >   opening shell output, but it gets much more interesting when I am
> >   looking at
> >
> >	   program | less
> >
> >   and I do not want to execute program again, and I also want to be able
> >   to go back to un-grepped output without executing program again.
> >
> >You can type |grep xxx | less, and this will open a sub-less with the
> >grep output in it.  To get back to the ungrepped file, just quit from
> >the sub-less.
> 
> Yes, only now the program isn't finished yet, and I want to do a 'F' (makes
> less act like tail -f) command.
> 
> This is not just some fun feature I want to have to look at, it comes in
> useful when you're looking at, say, a syslog, or program output. I have a
> window with my syslog, and I want to only see lines corresponding to a
> certain regexp. I don't know how to do that.
> 
> No, the regexp is not something I could use /etc/syslog.conf for. No
> dreaming. Anyway, modifying syslog.conf just for a few minutes is just
> terrible, and would only work for syslog in any case. In addition, if the
> less selected the lines for me, I would be able to quit that and see the
> context.
> 
> In effect, I want to put an egrep filter in less, with a regexp that could
> be modified without restarting less or re-reading file.
> 
> Hmmm ... there might be some specialized real-time log monitor which would
> let me do that ?
> 
> I think I'll be forwarding this to markn, less author. Should be rather
> simple, and ... is there anyone else that thinks it might be useful ?

You could, of course, use something like this:

tail -f logfile | grep regexp | less

or even something like:

tail -f logfile | grep regexp > /dev/tty10

Wouldn't that be sufficient? Only thing with grep (and some other
utilities) is, if stdout is not a tty it will use a buffer for stdout. The
first example probably won't work good enough for you. But how about the
second? 'grep' will keep working as long as 'tail' doesn't close the pipe,
which it won't until it exits.

Remco
-- 
blaakmeer:  1:40am  up 12:44,  7 users,  load average: 1.03, 1.11, 1.21


--
E-mail the word "unsubscribe" to debian-user-request@lists.debian.org
TO UNSUBSCRIBE FROM THIS MAILING LIST. Trouble?  E-mail to listmaster@debian.org .


Reply to: