---

Exercise 5: Managing the Structure of the awk file

“The awk file can have three parts which allow you to perform
various tasks and enhance your script and it’s usability. The three
sections are; BEGIN, BODY and END. The BEGIN section must have the
“BEGIN” text to indicate that it will be used. The BODY actually
does not need any reference so that anything you place in the BODY
section will execute just as if it was on the command line. A
script also allows you to run many different tasks throughout the
script. The END section must begin with the term “END”.

“Here is the basic awk file called records:

BEGIN {print “Start Evaluating records”}
NR > 12 {print “Number of Users is Now More Than 12”}
END {print “Total Number of Users: ” NR}


Complete Story

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis