bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] How to exit with a given exit code in END?


From: Andrew J. Schorr
Subject: Re: [bug-gawk] How to exit with a given exit code in END?
Date: Tue, 9 May 2017 10:21:34 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, May 09, 2017 at 08:40:19AM -0500, Peng Yu wrote:
> The following code will not finish. Is there a way to control the exit
> status code in END {}? Thanks.
> 
> awk -e 'END { exit 1 }'

The manual explains everything you need to know:

https://www.gnu.org/software/gawk/manual/html_node/Using-BEGIN_002fEND.html
https://www.gnu.org/software/gawk/manual/html_node/Exit-Statement.html

So, for example:

bash-4.2$ gawk 'BEGIN {exit 3}'
bash-4.2$ echo $?
3

Also, for such basic questions, you may find that the comp.lang.awk usenet
group is more appropriate.

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]