您好我有一个awk脚本并且不断收到错误^语法错误。 我不明白它在哪里,这里是代码:
BEGIN {
FS=" "
COUNT=0
}
m = substr($5,4,2)
if ($6 == DAY && m == MONTH)
{
COUNT++
}
END {
print DAY","MONTH
}
这里是我使用awk文件在我的脚本中写的行:
cat accident.txt | awk -v DAYS=$j -v MONTH=$i -f count-by-week-and-month.awk > $i.txt
答案 0 :(得分:2)
{}
出现错误,请尝试以下操作:
BEGIN {
FS=" "
COUNT=0
}
{
m = substr($5,4,2)
if ($6 == DAY && m == MONTH)
COUNT++
}
END {
print DAY","MONTH
}
缩短版本(不需要开始块.FS是默认空格,计数器为零)
{ m=substr($5,4,2)
if ($6 == DAY && m == MONTH)
COUNT++}
END {
print DAY","MONTH}