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 UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-10-2002
mfreemantle mfreemantle is offline
Registered User
 

Join Date: Feb 2002
Location: Sydney, Australia
Posts: 3
Question Regular expressions in sed

I'm using sed to alter a parameter file used in another process. Basically, the file is a template containing a few variables which need to be replaced at runtime.

The problem is that using sed with filenames that contain the / character causes matches to fail.

eg:
fileName=/mnt/someinputfile
sed -e "s/param1/${fileName}/g" somefile.txt > runfile

Could someone suggest how I can get around this?

Also, anyone know a good site for regexp?

=====================================
I've also tried doing an escaped forward slash substitution. ie. replace all "/" with "\\\/". It works outside the shell, but not inside. Wierd.

Here's the code fragment:

Code:
# 2 Modify the runCSjob.xml file: output to jobFile
subRunDate=`echo ${runDate}|sed -e "s/\//\\\\\//g"`;
substituteRunDate="1,\$s/\\\${runDate}/${subRunDate}/g";
subOutputFile=`echo ${outputFile}|sed -e "s/\//\\\\\//g"`;
substituteOutputFile="1,\\\$s/\${outputFile}/${subOutputFile}/g"
substituteRunType="1,\$s/\${runType}/${runType}/g";
sed -e "${substituteRunDate}" -e "${substituteOutputFile}" -e "${substituteRunType}" ${UTOPIA_BIN}/runCSjob.xml > ${tmpFile}.xml
Ideas??
__________________
:)
Mark

Last edited by mfreemantle; 02-10-2002 at 07:21 PM..
Remove advertisements
!!
!! Forum Sponsor