10

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?

  • 3
    If you run the stock OS X sed with the -E option, it should accept \t. See the re_format man page for details. – nwellnhof Jan 9 '15 at 14:27
  • It should, but it doesn’t. echo -e 'foo\tbar' | sed -E 's/\t/blah/' yields foo bar on Mavericks 10.9.5. – Will Aug 30 '15 at 22:40
11

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: <bug-sed@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
  • 1
    You don't need the PATH statements. Just brew install gnu-sed and it will be available as gsed – neu242 Jan 9 '15 at 9:39
  • 1
    The PATH statements lets you use the command sed instead of gsed. It's not necessary, but you won't need to remember to append the letter g to your sed command. – jherran Jan 9 '15 at 9:52
  • 2
    Sure. But that might interfere with programs that expect sed to be BSD sed. I don't know if that's a problem, but I'd expect it to be. (if osx then bsdisms) – neu242 Jan 9 '15 at 10:53
  • alias sed=gsed in a profile, maybe? – Kroltan Jan 9 '15 at 19:10
8

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).

4

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

  • thx, i was not aware of fink – javadba Jan 9 '15 at 8:52
  • 2
    Fink is getting quite old. I'd recommend Homebrew instead. – neu242 Jan 9 '15 at 9:40
  • 2
    @neu242 How is "old" a problem? Unix is 45 years old and we still use it. Fink itself is 6 years, long enough for the issues to be ironed out. Fink (and MacPorts) packages are updated regularly. – paul Jan 9 '15 at 11:26
  • @paul Oh, I've just never encountered anyone using Fink the last 10 years or so. Good to hear that it's still usable! :) – neu242 Jan 12 '15 at 12:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .