Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

2 Answers 2

up vote 7 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.:

share|improve this answer
The s of course... thanks :-) – Nilzor Apr 22 '12 at 11:41
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 at 7:44

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

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.