I know of python -c '<code>'
, but I'm wondering if there's a more elegant python equivalent to perl -pi -e '<code>'
. I still use it quite a bit for things like find and replace in a whole directory (perl -pi -e s/foo/bar/g *
or even find . | xargs perl -pi -e s/foo/bar/g
for sub-directories).
I actually feel that that which makes Perl Perl (free form Tim Toady-ness) is what makes perl -pi -e
work so well, while with Python you'd have to do something along the lines of importing the re module, creating an re instance and then capture stdin, but maybe there's a Python shortcut that does all that and I missed it (sorely missed it)...