Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 have a file xx that has the following contents:

@base_url = "http://dmstaffing-stage.herokuapp.com/"

I want to use sed to eliminate this line (replace with nothing). I have used this sed technique with several other line successfully, e.g.

sed -i 's/require "selenium-webdriver"//' xx

But my attempt for the @base_url line isn't working. I suspect either the " or the // in the http:// are messing it up but I can't seem to fix!

I have tried:

$ sed  's/@base_url = "http://dmstaffing-stage.herokuapp.com/"//' xx
sed: -e expression #1, char 23: unknown option to `s'

$ sed  's/@base_url = \"http://dmstaffing-stage.herokuapp.com/\"//' xx
sed: -e expression #1, char 24: unknown option to `s'

$ sed  's/@base_url = "http:\/\/dmstaffing-stage.herokuapp.com/"//' xx
sed: -e expression #1, char 58: unknown option to `s'

but none worked.

share|improve this question
up vote 5 down vote accepted

As mentioned, use other separator or escape the slashes. Your last try misses escape of last slash.

And as pointed out by @StephaneChazelas, escape dot's as well.

And, including @terdon if sed is not needed; grep -Fxv, where -F is fixed string, not regex, would be an option. -x makes sure it matches whole lines. -v inverts.

A simple (very simple) benchmark with time -v seems to favor sed though. (GNU variants.)

sed 's/@base_url = "http:\/\/dmstaffing-stage\.herokuapp\.com\/"//' xx

To delete it completely (not leave blank line) use:

sed '/@base_url = "http:\/\/dmstaffing-stage\.herokuapp\.com\/"/d' xx
                                                                +--- Delete
share|improve this answer
Stricktly speaking, you'd need to escape dots as well. To remove the line completely, use grep -xF '@base_url = "http://dmstaffing-stage.herokuapp.com/"' – Stéphane Chazelas May 15 '13 at 19:46
@StephaneChazelas I assume you meant grep -vxF? – terdon May 15 '13 at 19:57

Try using another separator:

sed  's|@base_url = "http://dmstaffing-stage.herokuapp.com/"||' xx
share|improve this answer

The slashes in the regex are messing up with sed's delimiters. But you can use different delimiters than the slash. For example:

sed  's#@base_url = "http://dmstaffing-stage.herokuapp.com/"##' xx
share|improve this answer

You can escape the slashes, like sed -e 's/"@base_url = "http:\/\/dmstaffing-stage.herokuapp.com\/"/d'. This jungle of /\/\//\// is a symptom of what is called LTS (Leaning Toothpick Syndrome). The best way around this is to just use another delimiter, like ; in your case, or whatever other non-alphanumeric character tickles your fancy today (and isn't included in whatever mangling you have in mind, obviously).

share|improve this answer

Your Answer


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.