-->
Page 581
printf("this is a second line of the header\n") > "report.txt"; } This is the header for page 1 this is a second line of the header the page number is now 0
The output is the same as that of Listing 27.6 except that the output shows up on the printer instead of the screen. Before printing the file, you have to close it.
This chapter provides you an introduction to the awk programming language and the GNU awk: gawk. It is a very powerful and useful language that enables you to search for data, extract data from files, create commands on-the-fly, or even create entire programs.
It is very useful as a prototyping languageyou can create reports very quickly. After showing them to the user, changes can be made quickly also. Although it is less efficient than the comparable program written in C, it is not so inefficient that you cannot create production programs. If efficiency is a concern with an awk program, it can be converted into C.
For further information, see the following:
Aho, Alfred V., Brian W. Kernighan and Peter J. Weinberger. The awk Programming
Language. Reading, Mass.: Addison-Wesley, 1988 (copyright AT&T Bell Lab).
See also the man pages for gawk on your system.
GNU awk, gawk, is available on this book's CD-ROM.
Page 582