Or even just this:
$SUM += /$regex/;
Update: Sorry, mine only counts the number of matches (like grep -c). To accumulate the values of matches, I still instinctively reach for (something like) this:
nawk '/([0-9]*)/{tot+=$1}END{print tot}' file
In reply to Re^2: reset of match variables
by hbm
in thread reset of match variables
by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |