Im trying to replace a number in a file with a calculated floating variable in a bash file. So im trying to replace 1.1111 with the value of "km" and save it in the mesh.in file. I keep getting an error on the sed line, I think there may be an issue with the floating variable. Echo "$km" does work so i know that the km is not the issue
#!/bin/bash
read -p "Angle in degrees : " n1
read -p "bcsa : " n2
cd viv_example_se2d
sed s/^bcsa.\*/"bcsa $n2"/ runfile.viv >temp
mv -f temp runfile.viv
cd ../
for i in $(seq 2 0.5 12)
do
if [ ! -d U*_$i ];then
mkdir U*_$i
fi
printf -v "km" "%.4f\n" $(echo | bc | awk "BEGIN {print 4*3.14159265359*3.14159265359/($i*$i)}")
echo "$km"
cd viv_example_se2d
sed s/1.1111/$km/g mesh_master.in > temp$i
mv -f temp$i mesh.in
cd ../
echo $home/lustre/projects/p057_swin/ogoldman/Ellipse_$n1/U*_$i | xargs -n 1 cp viv_example_se2d/*
done;