sed and double quotes

I have not seen anything yet in your forum to answer this problem.
Here is my sed command.
I want to change
Build Apache module" off
to
Build Apache module" on
This is what I am trying.

sed "s_Build Apache module\" off_Build Apache module\" on_" /usr/ports/lang/php5/Makefile /usr/ports/lang/php5/Makefile

Return is
Unmatched ".

I have tried double escaping double quotes but to no avail.

If I use single quote encapsulation it works but only prints to the screen.

Any help would be greatly appreciated.

You try this code

sed 's/Build Apache module\" off/Build Apache module\" on/g' inp_file

Here the inp_file contains the line as follows

Build Apache module" off

I got the output as follows

Build Apache module" on

Actually, you will find many more than this if you really search every thing

And this can do what you want...

sed 's#\(Build Apache module\"\) off#\1 on#' infile

Thank you for both answers.
Both answers were encapsulated in single quotes.
As I said, single quotes will change the output to the window but not change the file text.
Anyone else?

Try:

perl -i -ne 's/off$/on/g;print;' file
awk '/^Build Apache module/ gsub(/off/,"on",$0)' /usr/ports/lang/php5/Makefile

Another single quote encapsulted reply that will not change the file just the output to the screen. I am trying to replace text in an actual file.
I'm guessing I'm posting in the wrong place.
Thanks anyway.

triumdh,

If your shell support "sed -i" then you can edit the source file , other wise you can go for the perl solution suggested by Jacob.

Hi, how to replace a string with other string containing backslash in shell? Like I have to replace string PASSWORD with a variable that contains something like \#!\sfREVSDC/fsqWEQFWsdd\=\= . Basic sed is not working. it throughs error due to forward slash(/). If no forward slash, it works but backslash is being removed up on replace. Pls help on this using any shell script-need not be sed. Thanks in adv.

KHR

sed usually uses slashes, not underscores.

sed "s/Build Apache Module\" off/Build Apache Module\" on/g" whateveryourfilenamewas