5

I am trying to install GNU sed. Following this post I did

brew install gnu-sed

A priori it went fine, but then the command gsed is not found. I could not find any gnu-sed (or equivalent) in /usr/local/bin/ except the standard sed.

I am on Mac OS X 10.11.3

6
  • Try using find to find it. In Terminal, use the following command: find /usr -type f -name *sed Aug 3, 2016 at 1:58
  • Searching this way and selecting on those containing the term gnu, I found /usr/local/Cellar/gnu-sed/4.2.2/bin/sed. Should I just move this file to /usr/local/bin/? Thanks
    – Remi.b
    Aug 3, 2016 at 2:10
  • The OS X BSD version should be /usr/bin/sed, so I see no reason why you can't copy/move the GNU version to /usr/local/bin/. That said, depending on which is in your PATH first is the one that going to run if you don't do something to differentiate the two. Maybe call the GNU version gsed. Aug 3, 2016 at 2:16
  • Do I just have to rename the file sed to gsed to rename the command?
    – Remi.b
    Aug 3, 2016 at 2:20
  • The filename and the command name are essentially the same thing, so you can rename the file or not, that's up to you. You could also just leave the file where it is and create a symlink to it, named however you want. If you leave both named sed and both are in the PATH, then one is going to run over the other based on the PATH. If you don't understand what I'm saying, then you need to do some Googling. Aug 3, 2016 at 2:28

1 Answer 1

7

It would appear that the brew link process didn't successfully link from the Cellar to /usr/local/bin.

First, let's check that it installed. Try brew list and you will get a list of installed formulae. If gnu-sed is in there then it installed okay. If it's not, then run brew install gnu-sed again and you should be okay.

If it is in the list then try linking it and see what output you get. brew link gnu-sed will do this. It should link okay and you will be off and running.

5
  • Thanks. I did as you said. I also unlinked an relinked gnu-sed (brew unlink gnu-sed && brew link gnu-sed) and got Unlinking /usr/local/Cellar/gnu-sed/4.2.2... 3 symlinks removed;Linking /usr/local/Cellar/gnu-sed/4.2.2... 3 symlinks created. However the commands gnu-sed and gsed are still not found and I don't think the sed command has been replaced.
    – Remi.b
    Aug 3, 2016 at 17:54
  • Are you sure that /usr/local/bin is in your PATH? Aug 4, 2016 at 23:10
  • When I do echo $PATH I get /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin which seems pretty bad. All other bash commands work fine though.
    – Remi.b
    Aug 4, 2016 at 23:12
  • OK, your PATH is OK. Does /usr/local/bin/gsed exist? What happens if you cd /usr/local/bin and then ln ../Cellar/gnu-sed/4.2.2/bin/gsed /usr/local/bin/gsed ? Aug 9, 2016 at 7:33
  • /usr/local/bin/gsed does not exist. I only have /usr/local/bin/sed. /usr/local/Cellar/gnu-sed/4.2.2/bin/gsed does not exist either. Your ln command therefore returns No such file or directory. Thanks for keeping up with my issue :)
    – Remi.b
    Aug 9, 2016 at 17:55

You must log in to answer this question.

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