Hello,
Need a little bit of help. Basically I need to replace lines in a file which were calculated wrong as it would 12 hours to regenerate the data. I need to calculate values based on other files which I've managed to figure out with grep/cut but now am stuck on how to shove these new calculated values into another file
#!/usr/local/bin/bash
array=(61329025
61333750
61348174
61368157
61371144
61374807
61406775
61413072
61416814
61418304
61421223
61423127
61432337)
file2mod=sub_c18.csv
for i in "${array[@]}"
do
a=`grep $i sub_c11* |cut -f2 -d","`
b=`grep $i sub_c13* |cut -f2 -d","`
c=`grep $i sub_c7* |cut -f2 -d","`
ratio=`echo "$a+$b+$c-$a*$b-$a*$c-$b*$c" | bc -l`
printf "%s, %0.8f\n" $i $ratio>>sanitycheck.txt
sed -i "s/^a$i*//$i , $ratio/" $file2mod
done
echo "done"
sub_c18.csv looks like this
.
.
61406774,0.553508428
61406775,a2f14cf2
61406776,0.169964852
.
.
but it returns
sed: 1: "sub_c18.csv": unterminated substitute pattern
Thanks for any help.