The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-07-2008
CAGIRL CAGIRL is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 18
Help with find and replace w/string containing special characters

Can I get some help on this please, I have looked at the many post with similar questions and have tried the solutions and they are not working for my scenario which is:

I have a text file (myfile) that contains

b_log=$g_log/FILENAME.log
echo "Begin processing file FILENAME " >> $b_log

I have a script which contains a variable and tries to replace the string FILENAME in myfile with the value of var with the following commands:
var=/mydir/areally/really/really/deep/dir/structure/myfile.dat
perl -pi -e "s/FILENAME/\${var}/g" myfile

after I run the script the string FILENAME is removed but the value in var is not inserted.