Recursively search files named string.xml for certain text
You'll want to use find
for this, since grep
won't work that way recursively (as far as I know). Something like this should work:
find . -name "strings.xml" -exec grep "text" "{}" \;
The find
command searches starting in the current directory (.
) for a file with the name strings.xml (-name "strings.xml"
), and then for each found file, execute the grep
command specified. The curly braces ("{}"
) are a placeholder that find
uses to specify the name of the file it found. More detail can be found in man find
.
Also note that the -r
option to grep is no longer necessary, since find
works recursively.
You can use the grep command:
grep -r "text" /path/to/dir/strings.xml