Super User is a question and answer site for computer enthusiasts and power users. 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 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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .