Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-11 Thread Xah Lee
On Feb 11, 2:06 am, Alexander Gattin wrote: > Hello, > > On Tue, Feb 08, 2011 at 05:32:05PM +, Icarus > > Sparry wrote: > > 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,

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-11 Thread Alexander Gattin
Hello, On Tue, Feb 08, 2011 at 05:32:05PM +, Icarus Sparry wrote: > 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. many thanks to you, man! I'm surp

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-11 Thread Alexander Gattin
Hello, On Thu, Feb 10, 2011 at 07:52:34AM +0100, Petter Gustad wrote: > r...@rpw3.org (Rob Warnock) writes: > > invocation was given only one arg!! IT FOUND > > THE PATTERN, BUT DIDN'T TELL ME WHAT > > !@^%!$@#@! FILE IT WAS IN!! :-{ > > Sounds frustrating, but grep -H will always > print the fi

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Petter Gustad
r...@rpw3.org (Rob Warnock) writes: > invocation was given only one arg!! IT FOUND THE PATTERN, BUT DIDN'T > TELL ME WHAT !@^%!$@#@! FILE IT WAS IN!! :-{ Sounds frustrating, but grep -H will always print the filename, even when given a single filename on the command line. //Petter -- .sig remo

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Thomas L. Shinnick
At 09:39 PM 2/9/2011, Rob Warnock wrote: Harald Hanche-Olsen wrote: [snip] Years & years ago, right after I learned about "xargs", I got burned several times on "find | xargs grep pat" when the file list was long enough that "xargs" fired up more than one "grep"... and the last invocation was

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Rob Warnock
Harald Hanche-Olsen wrote: +--- | [Icarus Sparry ] | > The 'modern' way to do this is | > find . -maxdepth 2 -name '*.html' -exec grep whatever {} + | | Actually, I think it should be | find . -maxdepth 2 -name '*.html' -exec grep whatever /dev/null {} + \; | because grep behaves d

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Rob Warnock
Harald Hanche-Olsen wrote: +--- | [Icarus Sparry ] | > The 'modern' way to do this is | > find . -maxdepth 2 -name '*.html' -exec grep whatever {} + | | Actually, I think it should be | find . -maxdepth 2 -name '*.html' -exec grep whatever /dev/null {} + | because grep behaves diff

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Tassilo Horn
Xah Lee writes: >> You can rely on shell globbing, so that grep gets a list of all files in >> all subdirectories.  For example, I can grep all header files of the >> linux kernel using >> >>   % grep FOO /usr/src/linux/**/*.h > > say, i want to search in the dir > ~/web/xahlee_org/ > > but no mo

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Harald Hanche-Olsen
[Icarus Sparry ] > The 'modern' way to do this is > find . -maxdepth 2 -name '*.html' -exec grep whatever {} + Actually, I think it should be find . -maxdepth 2 -name '*.html' -exec grep whatever /dev/null {} + \; because grep behaves differently when given only one filename as opposed to sever

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-09 Thread Harald Hanche-Olsen
[Icarus Sparry ] > The 'modern' way to do this is > find . -maxdepth 2 -name '*.html' -exec grep whatever {} + Actually, I think it should be find . -maxdepth 2 -name '*.html' -exec grep whatever /dev/null {} + because grep behaves differently when given only one filename as opposed to several.

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Icarus Sparry
On Tue, 08 Feb 2011 14:30:53 -0800, Xah Lee wrote: > On Feb 8, 9:32 am, Icarus Sparry wrote: [snip] >> 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 '\

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Xah Lee
On Feb 8, 9:32 am, Icarus Sparry wrote: > On Tue, 08 Feb 2011 13:51:54 +0100, Petter Gustad wrote: > > Xah Lee 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 wha

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Petter Gustad
Icarus Sparry writes: > The 'modern' way to do this is > find . -maxdepth 2 -name '*.html' -exec grep whatever {} + Agree, I've noticed that recent version of find have the + option. I remember in the old days the exec method was considered bad since it would fork grep for each process, so I've

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Icarus Sparry
On Tue, 08 Feb 2011 13:51:54 +0100, Petter Gustad wrote: > Xah Lee 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 filenam

Re: How to Write grep in Emacs Lisp (tutorial)

2011-02-08 Thread Petter Gustad
Xah Lee 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 -- .s