Grep a Glob

04 Oct 2008
Posted by Jeet Sukumaran

Ever wanted to search a group of files, as specified by a glob pattern, for some content, as specified by a grep pattern?

find -path '' -exec grep -iHn {} \;

Note that the GLOB-PATTERN should be quoted to prevent the shell from auto-expanding wildcards before passing them to find.

Examples:

find /Applications -path "*.app/Contents/Info.plist" -exec grep -iH python {} \;

Tags:

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a biological visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.