How to search a group of files for a text string. …
To search for the string "foobar" (case insensitive) in all XML files in the working directory or any subdirectories, the form is:
$ egrep -rni foobar *.xml
The -r option recurses through any subdirectories. The -n option prints the names of the files with a match, the line number(s) of the matches in each file, and the lines containing the matches. The -i option ignores case in the pattern to be searched for. "*.xml" describes the files to be searched; use an asterisk to search all files.
To search for any of the strings "foo", "bar", and/or "baz" in all files:
$ egrep -rni '(foo|bar|baz)' *
If the files being searched have long lines, you might want to disable the printing of of the matching lines. To do this, substitute -l for -n above, which will print the names of the files with a match without printing lines.
If some of the files may be compressed, use zgrep. Unfortunately zgrep does not support recursion, so don't use the -r option with it.