🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Backquote question

Started by
10 comments, last by Oxyd 15 years, 3 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

Advertisement
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