This question already has an answer here:
I started using sed to replace text in files, to make it easier to mass change the contents of files, and I have each value that needs to be set as a variable with BASH and the replacement as a function that calls all of the variables to replace the existing text. Example~
sed -i -e "s/$answer/$FORME $answer/g" ~$answer.txt
$answer is the variable input with the command in terminal. $FORME is a variable that is defined depending on the input of $answer, however $FORME contains "/" and I have been browsing online and can't find a way to replace using variables that contain special characters. When I try to use the command on $answer's that create $FORME with a special character displays this error:
sed: -e expression #1, char 15: unknown option to `s'
I'm assuming that means that the special character in $FORME is registered as part of the actual command, not a string to replace. Please help!
Thanks in advance!