Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 4
    Count them, not sum them. Commented Jul 13, 2016 at 17:27
  • 2
    Thanks; answer modified for both variants, just for completeness :-) Commented Jul 13, 2016 at 17:29
  • 3
    print +tot instead of print tot to report 0 when no record qualifies Commented Jul 13, 2016 at 21:20
  • Merged in +tot and removed unneeded version (we have to learn to through away code. I know it is hard, so I did it for you). Commented Jul 13, 2016 at 21:34
  • 3
    Edit rolled back; I have no attachment to code that took zero effort to write. I left both versions there deliberately to show the similarities between the two versions, which can help people learning awk to recognise standard patterns and solutions. Commented Jul 14, 2016 at 4:05