Find all files with the name ending in ".txt" in the current directory and its subdirectories, and search for the string "foo" in each of those files, displaying the filename and the line containing the string.
find ~ -iname *.txt | xargs grep -H 'foo'