I am using sed in unix to replace some text with special characters in a file. I google it and find the following command
sed 's/from/to/g' file.txt
here 'from' is the original text being replaced, 'to' is the replace text
I am trying to apply this to a file with long text with special characters, i.e. replacing "/D/dec/prog/g++.exe -Wall --std=c++0x" (without quotation) to "SYSTEM_PATH/BIN", I try the following, but it doesn't work
sed 's//D/dec/prog/g++.exe -Wall --std=c++0x/SYSTEM_PATH/BIN/g' file.txt
but this come up with error "sed: -e expression #1, char 10: unknown option to `s'".
I am beginner of unix but for some reason I need to remotely login a unix server for handling some file. I want to know
1) how can I define the from and to string to a variable, something like FROMSTR = '/D/dec/prog/g++.exe -Wall --std=c++0x' TOSTR = 'SYSTEM_PATH/BIN'
so I can call the sed like sed 's/$FROMSTR/$TO/g' file.txt
but seems the sed don't know how to interpreate that as variable
2) after replacing the text by sed, it doens't write the result back to the original file. How to make it work?