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