[Home]
HomePage RecentChanges Frequently Asked Questions

END

The awk programming language allows us to use end blocks to provide [[finishoff?]] and [[cleanup?]] actions within the program.

Labelling

An end block is marked with the END label:

 END {
 # This is a begin block
 print "The end is here" # Print the closing message
 }

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.

Programming Convention

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

Multiple end blocks are executed in order in which they are defined.


Edit this page View other revisions Administration
Last edited 2011年04月30日 22:52 UTC by markhobley (diff)

Powered by sdf Creative Commons License <pierre.gaston+awk@gmail.com>

Awk Wiki by #awk is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.

AltStyle によって変換されたページ (->オリジナル) /