I'm new to awk, trying to understand the basics.
I'm trying to reset the counter everytime the program gets a new file to check.
I figured in the BEGIN part it would work, but it doesn't.
#!/bin/awk -f
BEGIN {counter=0}
{
sum=0
for ( i=1; i<=NF; i++)
{
sum += $i
}
if ( sum == copy)
{
counter += 1
}
copy=sum
}
END {
counter+=1
print counter
if(counter == NR)
{
print FILENAME " " "YES" " " sum
}
else
{
print FILENAME " " "NO" " " sum
}
}
Would appreciate your help.