Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
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.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Try the --include option

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

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

over 4 years ago · Santiago Trujillo Report

0

Use find:

find /path/to/dir -name '*.xml' -exec grep -H 'pattern' {} \;
over 4 years ago · Santiago Trujillo Report

0

I use this often:

grep 'pattern' /path/to/dir/**/*.xml

EDIT:

with zsh

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!