Using sed to replace a string in file with a string in a variable that contains spaces

Hi,

i call my shell like:

my_shell "my project name"

my script:

#!/bin/bash -vx

projectname=$1

sed s/'PROJECT_NAME  ='/'PROJECT_NAME  = '$projectname/ <test_config_doxy >temp
cp temp test_config_doxy

the following error occurres:

sed s/'PROJECT_NAME           ='/'PROJECT_NAME           = '$projectname/ <test_config_doxy >temp
+ sed 's/PROJECT_NAME           =/PROJECT_NAME           = my' project name/
sed: -e expression #1, char 54: unterminated `s' command

do i have to take the string apart by searching the spaces and do then something like:

sed s/'PROJECT_NAME           ='/'PROJECT_NAME           = '$string1' '$string2' '$string3/ <test_config_doxy >temp

or is there a clever alternative

Thanks!

---------- Post updated at 07:12 AM ---------- Previous update was at 06:05 AM ----------

sed s/'PROJECT_NAME ='/'PROJECT_NAME = '"$projectname"/ <test_config_doxy >temp

"$projectname" //just use quotation marks around the variable

Try this in your script:

sed 's/PROJECT_NAME  =/PROJECT_NAME  ='"$@"'/' file > newfile

thx a lot!