Sed question

From: Craig Russell (crussell_1969@yahoo.com)
Date: Thu Jan 27 2005 - 11:31:22 EST


I am trying to replace 10 lines in one file with 10
lines from another data file. The 10 lines I am
replacing I've setup with "holders" so they are easy
for sed to find. Thus line 1 is set to "holder1" the
2nd line is set to "holder2" and so on. The datafile
only has 10 lines and they are in the order that they
need to be inserted. My problem is that I cannot get
sed to recognize the variables within the substitution
command. This is what I am trying to use.

x=1
y=1
for i in 30 36 41 49 56 63 67 76 81 85
#replace matching line in file with $i
#and then write new line to new file
do
string=`sed -n "$x"p ./datafile`
echo $string
echo $x
sed 's/"holder$x"/"$string"/' ./template.$y
>template.$i
y=$i
x=`expr $x + 1`
done

This command currenlty gives no error messages but
does no substitutions. I have tried different quotes
around the variables (holder$x and $string). The
string variable is being set correctly. I have tried
escaping the variables with back slashes.

I apologize in advance if this is a newbie question.
I have been out of the sys admin field for a little
while and am admittedly a bit rusty.

Thank you

Craig Russell
xspaneteast
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:30:04 EDT