Using variable inside 'sed'

Dear all,

How can I amend the following command to use variable inside 'sed' ?

str=`sed -e 's/orig_string/${var}/g' ${sourcefile}`

Thanks,
Rocky

Use double quotes

str=`sed -e "s/orig_string/${var}/g" ${sourcefile}`

Also, if var is a path, then you'll need to use '\' before '/'. Sed substitutes first and then you still need to make sure you escape special characters such as '/'

Eg
set var="\/mydir\/path"
echo "my file /work/kofeyok/stuff/file.dat, r );" > testfile
sed -e "s/\/work\/kofeyok\/stuff/${var}/g" testfile > temp

temp should have
"my file /mydir/path/file.dat, r );"
without double quotes

set var="/mydir/path"
echo "my file /work/kofeyok/stuff/file.dat, r );" > testfile
sed -e "s#/work/kofeyok/stuff#${var}#g" testfile > temp