Linux Today: Linux News On Internet Time.

More on LinuxToday

Exercise 5: Managing the Structure of the awk file

Feb 22, 2011, 18:05 (2 Talkback[s])


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

"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

Related Stories: