Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
nawk(1) OSS Shell and Utilities Reference Manual
NAME
nawk - Manipulates text and matches patterns in files
SYNOPSIS
nawk -f program [-Fcharacter][file ...]
nawk [-Fcharacter] statement ... [file ...]
FLAGS
-Fcharacter
Uses character as the field separator character (a space by default).
-f program
Searches for the patterns and performs the actions found in the file program.
DESCRIPTION
The nawk command provides a flexible text-manipulation language suitable for simple report
generation. It is a more powerful tool for text manipulation than either sed or grep.
The nawk command:
• Performs convenient numeric processing.
• Allows variables within actions.
• Allows general selection of patterns.
• Allows control flow in the actions.
• Does not require any compiling of programs.
Pattern-matching and action statements can be specified either on the command line or in a pro-
gram file. In either case, nawk first reads all matching and action statements, then reads a line of
input and compares it to each specified pattern. If the line matches a specified pattern, nawk per-
forms the specified actions and writes the result to standard output. When it has compared the
current input line to all patterns, it reads the next line.
The nawk command reads input files in the order stated on the command line. If you specify a
filename as a - (dash) or do not specify a filename, nawk reads standard input.
Enclose pattern-action statements on the command line in ’’ (single quotes) to protect them from
interpretation by the shell. Consecutive pattern-action statements on the same command line
must be separated by a ; (semicolon), within one set of quotes. Consecutive pattern-action state-
ments in a nawk program file must appear on separate lines.
You can assign values to variables on the nawk command line as follows:
variable=value
The awk command treats input lines as fields separated by spaces, tabs, or a field separator you
set with the FS variable. (Consecutive spaces are recognized as a single separator.) Fields are
referenced as $1, $2, and so on. $0 refers to the entire line.
6−30 Hewlett-Packard Company 527188-007