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
  • 1
    Aha! it's obvious (now that I've seen your awk script :) ... There is no need to keep checking for min and max when the array is sorted :) and that means that the NR==1 can go (a useless-use-of-if) along with the min/max checks, so all initializing can be located in the BEGIN section (good!)... Allowing for comments is a nice touch too.. Thanks, +1 ... Commented May 26, 2011 at 2:28
  • Just a thought.. maybe allowing only numerics is better than disallowing comments (but that depends you your requirements).. Commented May 26, 2011 at 6:21
  • 2
    Technically, awk will assume "new" variables are zero, so in this case the BEGIN{} section is unnecessary. I've fixed the wrapping (no need to escape the line breaks either). I also used OFS="\t" to clean up the print line and implemented @Peter.O's second comment. (Yes, my regex allows ., but as awk interprets that as 0, that's acceptable.) Commented Jan 15, 2015 at 21:22
  • 1
    @AdamKatz - these are great changes, but as it stands, I didn't write the program. My awk script is now substantially different. I almost feel like you should take credit for the above program, in order to give credit where credit is due. Commented Jan 15, 2015 at 22:31
  • 1
    I wrote a perl script called avg that does this and more, by the way. Commented Aug 1, 2018 at 17:20