only recurses on directory
names passed to it. Globs expand into lists of matching names in the present working directory, so *
means you're passing it all files and directories in the pwd, and it recurses on the directory names. But *.xml
only expands into a list of the xml files in the pwd, and so there's nothing for it to recurse on.
So you have to make sure the top-level directories you want it to search are passed to it as arguments, and use --include
to control the matching of the filenames, as shown above. Or else use a tool like find
to generate the filelist first.
And read the grep info
page, which has more details about its operation than the man page.
@impert: In general, ls should not be be used for generating lists of filenames
. Most of the time you'll do better to use shell globbing
for simple matches, and find
for more complex ones (and use the null separator option).