I
have a text file with following details. I wanted to create a simple report as formatted
in the output. See a simple awk program to generate the report.

Content of text file

cat emp_dat

smith 800

allen 1600 300

ward 1250 500

jones 2975

martin 1250 1400

blake 2850

clark 2450

scott 3000

king 5000

turner 1500 0

adams 1100

james 950

ford 3000

miller 1300

awk program:

In
the program the portions marked in red color will excute only once. Moreover
the commands executed in the BEGIN and END will excute once to generate the
Header and footer. The commands marked in blue will repeat for the report body.