As the name suggests, the exit statement is used to immediately stop the execution of AWK script. On getting the exit statement at any place in AWK script, AWK stops executing current rule and current processing of input. Any remaining input if any is ignored. The syntax of the exit statement is as follows :
exit [ return status ]
It accepts an integer value as an argument to set the exit/return status of the AWK process. Supplying of a return status as an argument is optional. If no argument is given to the exit statement, it returns the exit status as zero.
If an exit statement is executed from the BEGIN statement, the program stops processing everything immediately and no input records are read. And if an END statement is present, ...