Last edit
Summary: updates from markhobley.yi.org
Deleted:
< == Execution
< An **end block** is executed once only, after the last input record is read.
< == An end block must contain actions
< A **end block** must contain actions, and there is no default action provided for an end block, because an end block executes after the last input record has been read, so there is no current record when an **end block** is run.
Added:
> == Execution
> End blocks can are executed once only, after the last input record is read.
> == End blocks must contain actions
> There is no default action for end blocks, so end block must contain defined actions. An end block must contain actions.
> == There is no current record information available within an end block
> There is no current record information available within an end block, because end blocks are executed after the last input record has been read.
Changed:
< When multiple **end blocks** are defined within a program, they are executed in order that they are defined.
to
> Multiple end blocks are executed in order in which they are defined.
The awk programming language allows us to use end blocks to provide [[finishoff?]] and [[cleanup?]] actions within the program.
An end block is marked with the END label:
END { # This is a begin block print "The end is here" # Print the closing message }
End blocks can are executed once only, after the last input record is read.
There is no default action for end blocks, so end block must contain defined actions. An end block must contain actions.
There is no current record information available within an end block, because end blocks are executed after the last input record has been read.
The original version of awk required the *end block* to be placed at the end of the program and only one end block was allowed. This is no longer a requirement of current awk versions, however it is recommended that this convention is observed for portability and readability purposes.
Multiple end blocks are executed in order in which they are defined.