Find all files with the name ending in ".txt" in the home directory, and for each of them, execute the command "sed -i 's/foo/bar/g' {}", where {} is the file name.
find ${HOME} -depth -iname "*.txt" -exec sed -i 's/foo/bar/g' {} \;