How to Write grep in Emacs Lisp (tutorial)

Icarus Sparry i.sparry+un at gmail.com
Tue Feb 8 18:32:05 CET 2011


On Tue, 08 Feb 2011 13:51:54 +0100, Petter Gustad wrote:

> Xah Lee <xahlee at gmail.com> writes:
> 
>> problem with find xargs is that they spawn grep for each file, which
>> becomes too slow to be usable.
> 
> find . -maxdepth 2 -name '*.html -print0 | xargs -0 grep whatever
> 
> will call grep with a list of filenames given by find, only a single
> grep process will run.
> 
> //Petter

This is getting off-topic for the listed newsgroups and into 
comp.unix.shell (although the question was originally posed in a MS 
windows context).

The 'modern' way to do this is
find . -maxdepth 2 -name '*.html' -exec grep whatever {} +

The key thing which makes this 'modern' is the '+' at the end of the 
command, rather than '\;'. This causes find to execute the grep once per 
group of files, rather than once per file.




More information about the Python-list mailing list