I have a directory containing a vast amount of xml files. I would now like to find the number of files (and optionally the names of said files) that contain a certain string. XML tags do not really matter, each of the files can be seen as text files.

I have found a similar question here, but this will output the whole file content. I am only interested in the filenames and the number of files that contain the given string.

1 Answer 1


Here are commands run from inside the directory.

number of files:

grep -l text *.xml |wc -l

file names:

grep -l text *.xml

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .