Find all directories in the current directory, then find all files with the name ending in ".txt" and replace all occurrences of "foo" with "bar" in those files.
find $(ls -d */) -type f -iname "*.txt" -exec sed -i 's/foo/bar/g' {} \+