Tuesday, March 25, 2008

Sed tricks

Find something in files and replace it with something else.
find . -name "somefiles" -exec sed -i 's/this/that/' {} \;

For an or condition...
sed 's/this/that/g;s/other/totheother/g'

Hey guess what, that inline flag -i doesn't work with Solaris 8's default sed install. We've already badgered our Solaris admin enough for one day, what else can we do?

Perl pie.

perl -pi -e 's/foo/bar/g' filename*


No comments: