I have to spend a fair bit of time at work hacking away on Solaris boxes and have really started to miss some of the extra features of many GNU tools I really took for granted. One that really bugs me is the lack of in-place editing in Solaris sed (-i using GNU sed). Perl to the rescuse!
perl -pi -e 's/foo/bar/g' /path/to/file
The above is pretty functionally equivalent to sed -i. A quick alias in .bashrc:
alias sed-i='perl -pi -e'
and everything in life is well again.
2 Comments so far
Leave a comment
Thanks - that was exactly what I needed for Solaris! All documentation I could find referred to the sed ‘-i’ option which seems to only be available in later GNU or Linux versions of sed.
Rob Goretsky // Thursday April 10 2008 // 7:13 pm | Permalink
No problem, glad it was useful for someone else.Thankfully OpenSolaris is working towards providing a more complete GNU userland.
Ben // Thursday April 10 2008 // 7:13 pm | Permalink
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed.