Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

BEGIN and END section in awk

awk statements are usually applied to all lines selected by the address, and if there are no address, then they are applied to every line of input. But if we like to Print something before Processing the first line, for example, a heading, then the BEGIN section can be used quite gainfully. Similarly, the END section is useful in printing some totals after the processing is completed.

The BEGIN section and END section are optional and take the form
                                              BEGIN  {action}                      #Both require curly braces
                                              END      {action}

The BEGIN section is used to print something before processing the first line, whereas, The END section is used to print something after processing all the lines.

awk statements are usually applied to all lines selected by the address, and if there are no address, then they are applied to every line of input. But if we like to print something before processing the first line, for example, a heading, then the BEGIN section can be used quite gainfully. Similarly, the END section is useful in printing some totals after the processing is completed.

The BEGIN section and END section are optional and take the form
                                              BEGIN  {action}                      #Both require curly braces
                                              END      {action}

The BEGIN section is used to print something before processing the first line, whereas, The END section is used to print something after processing all the lines.


This post first appeared on BCA MCA NOTES, please read the originial post: here

Share the post

BEGIN and END section in awk

×

Subscribe to Bca Mca Notes

Get updates delivered right to your inbox!

Thank you for your subscription

×