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
  • Can ever the same BEGIN block be usefully used for both applications with and without input? If not, why not call exit from the BEGIN block? Commented Mar 30, 2018 at 23:21
  • Instead of using exit you can call system() and kill the awk process directly. Commented Mar 30, 2018 at 23:27
  • The END blocks are probably executed in the order in which they appear. So if your BEGIN block calls exit and the first END block (in your helper script) calls exit again then the "real" END blocks should not get executed. Commented Mar 30, 2018 at 23:32
  • seems a bug? awk(1) on my system says exit should "exit immediately" and nothing about going on to END blocks Commented Mar 30, 2018 at 23:54
  • 6
    The fact that END executes even after explicit exit is documented: gnu.org/software/gawk/manual/html_node/Exit-Statement.html Commented Mar 31, 2018 at 4:56