building sed for osx

I work in linux a lot… not bsd. So the OSX (bsd style) implementation of sed really throws me for a loop when I go text-file-spelunking, whats worse is that my scripts using sed aren’t portable between the two OSs.

A quick googling this morning landed me here: http://wiki.octave.org/wiki.pl?OctaveForMac which gives perfectly good instructions on installing sed. except it didnt work. I grabbed the latest version of sed (4.1.5) and got the error

sed: 1: "install_sh=/Users/apoka ...": command i expects \ followed by text
sed: 1: "install_sh=/Users/apoka ...": command i expects \ followed by text

Ironic, huh? Well taking a guess that at some point sed hadcome to depend on its own functionality to configure itself I jumped back a version… Figuring i replace BSD sed with an out of date GNU sed, and then use the old GNU sed to build the new GNU sed. Which worked great. I Installed first sed-3.0.2, and then 4.1.5 in this manner:

./configure --prefix=/usr/ --with-included-regex --with-included-gettext && make && sudo make install

I’m happy with my -r again…

# date | sed -r s/'[0-9]‘/’?'/g
Thu Apr ?? ??:??:?? PDT ????

Posted on : Apr 24 2008
Posted under Personal, Software Development, cli, linux, osx |

2 People have left comments on this post

Apr 26, 2008 - 12:04:29
Joseph Scott said:

For BSD sed you can use -E, which does the same thing as -r in GNU sed.

Apr 26, 2008 - 12:04:18
apokalyptik said:

You absolutely can, and up till now i have. still doesn’t help when you spend a lot of time in both, and like to be able to copy and paste one-liners between the two… doesn’t feel right to have to sed your sed scripts… ya know?