linux: search text in files matching specific name

Combination of “find” and “grep” as follows:

find . -type f -name "*.xml" -exec grep -H "<needle>" {} \;

notes: this example is searching for files in current folder (“.”) with name ending in “.xml” (“*.xml”) and looking having word “<needle>”, -H option will print names of files for which condition is matched

sources

 

Post a Comment

Your email is never published nor shared. You're allow to say what you want...