I have an Android
project in which I have strings.xml
and other .xml
files defined in various places depending upon language and other criteria.
There are directories like -
> /res/values-en-rUS/strings.xml > /res/values-es-rUS/strings.xml > /res/values-fi/strings.xml > /res/values-it/strings.xml > /res/values-ms/strings.xml > /res/values-bn/strings.xml > /res/values-da/strings.xml > /overlay_dir/TN_KOR_COMMON/res/values/strings.xml > /overlay_dir/TN_KOR_COMMON/res/values-en-rUS/strings.xml > /overlay_dir/TN_KOR_COMMON/res/values-ko/strings.xml > /overlay_dir/TN_JPN_COMMON/res/values-ja/strings.xml > /res/layout/hovering.xml > /res/xml/settings_menu.xml
Now, I want to find a string in only files in directories which have paths like /res/values-en-rUS
and /res/xml
.
I used the command -
grep -i "hovering_msg" `find -path "*@(values-en-rUS|xml)*" -iname "*.xml"`
but it doesn't seem to work. According to my understanding *@(values-en-rUS|xml)*"
means find a number of characters followed by either values-en-rUS
or xml
followed by any number of characters. Can someone tell me where I am going wrong?
I assume that you worked in bash env.
You have used extend globbing
, so you have to turn it on first by:
shopt -s extglob
And for your task, you don't have to combine grep
and find
, you can do:
grep -i 'pattern' /res/@(values-en-rUS|xml)/*.xml
For source codes searching, I recommend ag (silver searcher).