Pattern matching against the directory part with -path
or -regex
is possible as well but it would be simpler to just specify both target directories than trying to match patterns against them. This would save execution time since it wouldn't try to search files in other directories.
find /res/values-en-rUS /res/xml -iname '*.xml'
With grep
:
grep -i "hovering_msg" `find /res/values-en-rUS /res/xml -iname '*.xml'`
Besides splittng output of command substitution with backquotes, it is also be possible to use while read
from a pipe to also allow spaces in filenames:
find /res/values-en-rUS /res/xml -iname '*.xml' | while read file; do
grep -i "hovering_msg" "$file"
done
If you're in a Linux box, using xargs
would be the better option:
find /res/values-en-rUS /res/xml -iname '*.xml' -print0 | xargs -0 -d '\n' -- grep -i "hovering_msg" --