Find all files with the name ending in ".txt" in the current directory and its subdirectories, and replace all occurrences of "grep" with "sed" in each of those files.
find ~ -iname '*.txt' -exec sed -i 's/grep/sed/g' {} \;