Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

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.: 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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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