Find all files with a ".txt" extension in the current directory and its subdirectories, and replace all occurrences of "string1" with "string2" in each file.
find ~ -type f -name "*.txt" -exec sed -i 's/string1/string2/g' {} \;