5

I feel like a total newb. Why does this not work?

$ echo foobar > textfile
$ sed /foo/bar/ textfile
sed: can't find label for jump to `ar/'

I've also tried sed "/foo/bar/" textfile and sed '/foo/bar/' textfile, which all yields the same error.

Using ubuntu 8.04 and GNU sed version 4.1.5 through bash.

8

Try this: sed 's/foo/bar/' textfile.

  • Quotes around the statement are good practice
  • s for substitute. It is the command you want to execute. foo is the search term bar the replacement.

There is a lot of information on sed online. Eg.: http://www.catonmat.net/blog/sed-one-liners-explained-part-one/

| improve this answer | |
2

You need to give sed a command; it parsed what you gave it as a search pattern /foo/ followed by the command b ar/ (branch to label ar/). You probably meant 's/foo/bar/' meaning replace the first instance of foo with bar in every line.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.