Find all files with the extension .txt in the current directory and its subdirectories up to 3 levels deep 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'