【发布时间】:2017-02-28 03:16:58
【问题描述】:
我得到 (FILENAME=123.dat FNR=2) 致命:在以下脚本中尝试除以零的错误。下一个命令是否会忽略以下两个代码块并开始执行第二条记录的代码。如果不是这种情况,我怎么能忽略文件第一条记录上的任何代码执行?
awk ' BEGIN {
FS="<[^>]+>";
RS="";
review1=1;
review2=1;
rating=0;
criteria=7;
}
#ignores the first record of each file
FNR<2 { next }
FNR==NR {
#sums all the ratings of an authors
for(i=8; i<=14;i++) {
rating+=$i;
}
#stores the average rating of each author
sum1+=rating/criterias;
#stores each average rating
total1[review1]=rating/criteria
review1++;
rating=0;
}
FNR!=NR {
.... code
}
END {
#calculates the mean(overall rating) for hotel1
mean1=sum1/review1;
printf("Mean hotel_1: %.2f\n",mean1);
} ' "$2" "$3"
【问题讨论】:
标签: awk