following script to perform string substition with 'sed' does not work, can anyone see what the problem is? thanks
#!/bin/ksh
# a file has a header record followed by detail records;
# variable text in positions 1-19 on all detail records must be changed to some constant text
# pattern to be replaced is obtained from record no. 2 positions 1-19:
source_file=$1
tmp_file=$source_file$$
oldtext="`sed -n -e '2p' ${source_file} | cut -c1-19`"
newtext="CHANGED TEXT"
echo $oldtext $newtext
sed '2,$ s/${oldtext}/${newtext}/g' ${source_file} > ${tmp_file}
mv $tmp_file $source_file
#!/bin/ksh
# a file has a header record followed by detail records;
# variable text in positions 1-19 on all detail records must be changed to some constant text
# pattern to be replaced is obtained from record no. 2 positions 1-19:
source_file=$1
tmp_file=$source_file$$
oldtext="`sed -n -e '2p' ${source_file} | cut -c1-19`"
newtext="CHANGED TEXT"
echo $oldtext $newtext
sed '2,$ s/${oldtext}/${newtext}/g' ${source_file} > ${tmp_file}
mv $tmp_file $source_file