Reputation: 13
find . -name "*.txt" | xargs grep "text"
fail when file name has spaces
How to make this to work with filename with spaces
Upvotes: 1
Views: 2012
Reputation: 113834
This will work for all file names and it will also be slightly more efficient because it avoids the need for a pipeline:
find . -name "*.txt" -exec grep "text" {} +
Upvotes: 2