Reputation: 157
Hi I've got a awk script and keep getting the error ^ syntax error. i don't understand where it is, here is the code :
BEGIN {
FS=" "
COUNT=0
}
m = substr($5,4,2)
if ($6 == DAY && m == MONTH)
{
COUNT++
}
END {
print DAY","MONTH
}
here the line i write in my script using the awk file:
cat accident.txt | awk -v DAYS=$j -v MONTH=$i -f count-by-week-and-month.awk > $i.txt
Upvotes: 0
Views: 72
Reputation: 41446
You have some error with {}
, try this:
BEGIN {
FS=" "
COUNT=0
}
{
m = substr($5,4,2)
if ($6 == DAY && m == MONTH)
COUNT++
}
END {
print DAY","MONTH
}
Shorten version (begin block is not needed. FS is default space, and counter is zero)
{ m=substr($5,4,2)
if ($6 == DAY && m == MONTH)
COUNT++}
END {
print DAY","MONTH}
Upvotes: 2