6. Programming example
a. Create gawk files having commands in it.
[root@kalwa1 tmp]# cat gawk.1 {print} [root@kalwa1 tmp]#
Now from command prompt give following command:
gawk -f gawk.1 students
Example:
[root@kalwa1 tmp]# gawk -f gawk.1 students Manmohan 286 555-5574 manmohan 8 Atul 280 555-4221 atul 10 Anshul 279 555-1112 anshul 2 Romel 284 555-2121 shrikant 12 [root@kalwa1 tmp]#
b. Now create the following second program named it as “gawk.2”
[root@kalwa1 tmp]# cat gawk.2 BEGIN { print "Students for UX Techno"; print; } {print} [root@kalwa1 tmp]#
Now from command prompt give following command:
gawk -f gawk.2 students
Example:
[root@kalwa1 tmp]# gawk -f gawk.2 students Students for UX Techno Manmohan 286 555-5574 manmohan 8 Atul 280 555-4221 atul 10 Anshul 279 555-1112 anshul 2 Romel 284 555-2121 shrikant 12 [root@kalwa1 tmp]#
Leave a Reply