Advertisement

Backquote question

Started by March 04, 2009 02:21 PM
10 comments, last by Oxyd 15 years, 8 months ago
Quote: Original post by Oxyd
Quote: Original post by Sander
How about `ls -1` then? :-)

Definitely much more useful. [smile]

Quote: Original post by ToohrVyk
I commonly use grep foobar `find . -name '*.php'` as a find-in-files operation.

Does that have any advantage over find . -name '*.php' -exec grep foobar {} ';'?

Absolutely: the first will barf when the command-line length limit is reached but will prepend the filename for each match line. The second is slow because it forks for every single file encountered and will not prepend the filename for every match line.

The correct answer is find . -name '*.php' | xargs grep foobar

Stephen M. Webb
Professional Free Software Developer

Quote: Original post by Bregma
Absolutely: the first will barf when the command-line length limit is reached but will prepend the filename for each match line. The second is slow because it forks for every single file encountered and will not prepend the filename for every match line.


Ah! That could also be achieved by find . -name '*.php' -exec grep -H foobar {} '+', if I'm reading the manpages correctly.

This topic is closed to new replies.

Advertisement