bash - How do you grep results from 'find'? -


trying find word/pattern contained within resulting file names of find command.

for instance, have command:

find . -name gruntfile.js returns several file names.

how grep within these word pattern?

was thinking along lines of:

find . -name gruntfile.js | grep -rnw -e 'purifycss'

however, doesn't work..

use -exec {} + option pass list of filenames found arguments grep:

find -name gruntfile.js -exec grep -nw 'purifycss' {} + 

this safest , efficient approach, doesn't break when path file isn't "well-behaved" (e.g. contains space). approach using xargs, minimises number of calls grep passing multiple filenames @ once.

i have removed -e , -r switches, don't think they're useful here.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -