z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Program files

z/OS UNIX System Services User's Guide
SA23-2279-00

A program file is a text file that contains an awk program. You can create program files with any text editor (such as ed). For example, you might create a file named lbprog.awk that contains the lines:
$1 == "Linda"
$2 == "bridge" { print $1 }
To execute a program on a particular data file, use the command:
awk –f progfile
datafile
where progfile is the name of the file that contains the awk program, and datafile is the name of the data file. For example:
awk –f lbprog.awk hobbies
runs the program in lbprog.awk on the data in hobbies.
If the data file does not use the default separator characters, you must specify a –F option after the progfile name, as in:
awk –f prog.awk –F":" file.dat

To gain some experience using awk, you can test the examples on the hobbies file. Run some from the command line and some from program files.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014