Find all files with the extension ".txt" in the current directory and its subdirectories, and replace all occurrences of "word1" with "word2" in those files.
find ~ -name "*.txt" | xargs sed -i 's/word1/word2/g'