[H-GEN] Useful not so obvious tips

Greg Black gjb at gbch.net
Tue Oct 26 02:12:35 EDT 2004


On 2004-10-26, Anthony Towns wrote:
> On Tue, Oct 26, 2004 at 02:54:30PM +1000, Greg Black wrote:
> > Then I adjust stuff until it narrows it down to a likely set of
> > file names and then do
> >     find . -type f -print0 | xargs -0 grep -l newstuff | xargs -0 less
> 
> I tend to find:
> 
>     less $(find . -type f -print0 | xargs -0 grep -l newstuff)
> 
> preferable here -- otherwise you're relying on less noticing that it can't
> use stdin to talk to you (stdin has already been taken over by the pipe to
> xargs) and making use of /dev/tty. Which is fine for less, but can cause
> problems for other programs, which naturally don't come to mind right now.

The obvious example is vi, but the way I tend to do this is the
way I showed, since I'll be using less to scan the files looking
to see if I have the one(s) I want.  Then, when I find the right
file(s) I use less's v command to edit them or save them to some
suitable location.

> (Ctrl-A gets you to the start of a line to add the `less $(', Ctrl-E to
> the end of it, btw)

Yup, it's certainly not at all hard to use those keys, and I do
recommend that people spend time learning the full range of
stuff provided by their shell.  You'll never use it all, but it
can be surprisingly helpful to have an understanding of the sort
of things that are typically on offer.

Cheers, Greg




More information about the General mailing list