Find all files with the extension ".txt" and for each of them, execute a command that replaces all occurrences of "foo" with "bar" in the file.
find -name "*.txt" | xargs -I {} sh -c "sed -i 's/foo/bar/g' {}"