我一直在尝试运行以下 bash 脚本,但出现错误:
awk: cmd. line:1: -
awk: cmd. line:1: ^ unexpected newline or end of string
我一直试图找出问题所在,但无济于事。我需要为一个项目紧急运行脚本,所以任何帮助将不胜感激!
输入文件(称为“输入”):
0 13 1495.015 1495.02d0 3.03607E-09 0.000000 0.00000E+00
0 14 1598.750 1598.57d0 1.90704E-09 0.000000 0.00000E+00
0 15 1701.372 1700.87d0 1.26357E-09 0.000000 0.00000E+00
0 16 1803.382 1802.22d0 9.11215E-10 0.000000 0.00000E+00
0 17 1906.131 1904.54d0 7.17855E-10 0.000000 0.00000E+00
0 18 2009.553 2007.55d0 5.88960E-10 0.000000 0.00000E+00
0 19 2113.543 2110.84d0 4.86193E-10 0.000000 0.00000E+00
0 20 2217.641 2214.16d0 4.09698E-10 0.000000 0.00000E+00
0 21 2321.638 2317.24d0 3.53609E-10 0.000000 0.00000E+00
0 22 2426.151 2420.84d0 3.12269E-10 0.000000 0.00000E+00
0 23 2530.983 2524.70d0 2.80847E-10 0.000000 0.00000E+00
0 24 2636.078 2629.18d0 2.52442E-10 0.000000 0.00000E+00
脚本开始:
largesep_obs=103.188
avg_n="`awk '{sum_n+=$2} END{avg=sum_n/NR; print(avg)}' input`"
avg_ref="`awk '{sum_ref+=$3} END{avg=sum_ref/NR; print(avg)}' input`"
avg_obs="`awk '{sum_obs+=$4} END{avg=sum_obs/NR; print(avg)}' input`"
num="`awk -v avg_n=$avg_n -v avg_obs=$avg_obs '{sum+=($4-avg_obs)*($2-avg_n); print(sum)}' input`"
den="`awk -v avg_n=$avg_n '{sum+=($2-avg_n)**2}' input`"
largesep_ref=$num/$den
r=1
nu_not=2000
b="( $r*$largesep_ref/$largesep_obs-1 )*( $r*$avg_ref/$avg_obs-1 )**-1"
den_of_a=`awk -v avg_obs=$avg_obs -v avg_ref=$avg_ref -v nu_not=$nu_not -v b="$b" '{sum+=(($4/nu_not)**b)} END{ans=sum/NR; print(ans)}' input`
a=($avg_obs - $r*$avg_ref)/$den_of_a
no_of_rows=12
awk -v nu_not=$nu_not -v r=$r -v a=$a -v b=$b -v no_of_rows=$no_of_rows '\"{
for (x=1; x<=no_of_rows; x++) {
array[x]=r*$3 + a*(($4/nu_not)**b)
print("%s", vector[x])
print("\n")
}
}'\" input