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
  • 1
    +1 Slightly more complete than the accepted solution, although imho your 2nd NR>FNR at the end is as awkward (pun intended) as it is necessary to print things out. Commented Sep 16, 2020 at 8:45
  • 1
    @Cbhihe True. Although I usually try to make the code readable rather than "golfed", writing it this way is shorter than having next in the first and print in the second rule ;) Commented Sep 16, 2020 at 9:00
  • 1
    Mmmh...I'm with you for not golfing in this forum, but with next in 1st rule's set of braces, you could do away with NR>FNR in the 2nd rule, AND replace the last occurrence of NR>FNR with {print}. This was exactly what I was thinking, but decided not to mention it earlier, because style is... style. It's hard to argue against it, especially if the answer is flawless. ;-) Commented Sep 16, 2020 at 9:14
  • @Cbhihe True, that is indeed a way to make it more efficient. I will keep it in mind for future answers :) Commented Sep 16, 2020 at 9:17