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*

4
  • Empty file gets a fatal divide-by-zero. print (NR ? sum / NR : "NaN") Commented Dec 20, 2019 at 16:15
  • 6
    @Paul_Pedant: Don't use it on an empty file. Commented Dec 20, 2019 at 16:16
  • I wouldn't. But users are a whole new thing. I like your initialising from NR==1. I use BEGIN and some arbitrary max and min, and it always looks clumsy. Commented Dec 20, 2019 at 16:19
  • 4
    If it's being run against an empty file it should error IMO because something has been done wrong. Commented Dec 20, 2019 at 16:20