Find all files with the extension ".py" in the current directory and its subdirectories, and replace all occurrences of "foo" with "bar" in those files.
find ~ -iname "*.py" | xargs sed -i 's/foo/bar/g'