The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 11-23-2007
kofeyok kofeyok is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 1
Smile

Quote:
Originally Posted by anbu23 View Post
Use double quotes
Code:
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