Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grep a word inside xml files in a folder

I know I can use grep to find a word in all the files present in a folder like this

grep -rn core .

But my current directory has many sub-directories and I just want to search in all xml files present in the current directory and its all sub directories. How can I do that ?

I tried this

grep -rn core *.xml // Does not work

But it searches for xml files present in the current directory only. It does not do it recursively.

like image 290
Sachin Avatar asked Jan 29 '14 10:01

Sachin


1 Answers

Try the --include option

grep -R --include="*.xml" "pattern" /path/to/dir

Reference: Grep Include Only *.txt File Pattern When Running Recursive Mode

like image 114
Chris Maes Avatar answered Sep 27 '22 20:09

Chris Maes