Find all files with the extension .txt in the current directory and up to 3 levels of subdirectories, and replace all occurrences of the word "foo" with the word "bar" in those files.
find . -maxdepth 3 -name '*.txt' | xargs sed -i 's/foo/bar/g'