Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 8 down vote accepted

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/

share|improve this answer
    
The s of course... thanks :-) – Nilzor Apr 22 '12 at 11:41
1  
Don't forget to mark this answer as 'accepted answer'. – OrangeTux Apr 22 '12 at 12:21

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.

share|improve this answer

protected by Community Jul 23 '15 at 7:44

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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