Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to look for all XML files in a particular directory and all sub-directories (recursively) inside it.

ls -R *.xml is only listing files in the current directory. I am quite sure, the sub-folders themselves have several .xml files, but none are showing up.

Is this a configuration issue?

share|improve this question
add comment

4 Answers 4

Try using Find

sudo find . -print | grep -i '.*[.]xml'
share|improve this answer
is the sudo must, or it's there to ensure super user privileges? –  Shamim Hafiz Jun 13 '13 at 20:36
I let you decide. Sudo, No Sudo. –  Mitch Jun 13 '13 at 20:44
If this answered your question, you may mark this answer as accepted. –  Mitch Jun 13 '13 at 21:57
Just out of interest. What is the advantage of find over ls -R? –  don.joey May 22 at 9:21
@don.joey This might help stackoverflow.com/questions/13830036/… –  Mitch May 22 at 10:08
add comment

Try this command:

ls -R | grep '.*[.]xml'

ls doesn't have options to filter the output. For that you would need to use pipe. This passes the output from ls to grep, which then filters them to show just the .xml files.

share|improve this answer
add comment

You can do it with find only:

find . -name *.xml

. is the current directory. If you need to search in another directory, replace . with the directory path.

share|improve this answer
add comment

This would work too.

find /path-dir -type f | xargs grep *.xml

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.