Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I read somewhere that:

sed -n -e '/foo/d' myinputfile.txt

would remove all occurences of 'foo' from myinputfile.txt.

However this does not seem to work for me. I am a sed noob and cannot seem to work this out. I am basically trying to run a bash script that calls sed on each line to remove a word from the input file and nothing happens when I run it.

Thanks :)

share|improve this question

1 Answer 1

You read incorrectly.

However, while the sed expression itself is correct, the flags are not. sed normally outputs each line as it processes it to stdout, but -n suppresses this. The end result is that no lines are output. You must remove the -n if you want the proper output. You can then redirect this into another file, and then move that file into place.

share|improve this answer
    
Thank you! That cleared my issue up. :) –  isildur Jul 30 '12 at 0:39
    
@isildur maybe you can add option -i to sed (check manual, not only sed version). –  uzsolt Jul 30 '12 at 10:13

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.