Where is a reasonable sed?

On Yosemite. The sed is old: does not understand \t for example. I installed coreutils and can not find any sed associated with same.

What are my options here?


Solution 1:

You need to install gnu-sed, not just the coreutils:

brew install gnu-sed

Then, you have to add the following lines on your .bash_profile:

export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
export MANPATH="/usr/local/opt/gnu-sed/libexec/gnuman:$MANPATH"

Then your sed version should be the latest:

$ sed --version
sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <[email protected]>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.

Solution 2:

Your question is tagged homebrew, but for those readers using MacPorts: Run sudo port install gsed to get GNU sed (available with the gsed command, similarly to gfind in the findutils port).

Solution 3:

Install fink . You will also need XCode if you haven't got it already.

Then install the latest sed (and lots of other useful things) like this:

fink install sed