Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)

User Commands (m - o) nawk(1)
NAME
nawk - Manipulates text and matches patterns in les
SYNOPSIS
nawk -f program [-Fcharacter][le ...]
nawk [-Fcharacter] statement ... [le ...]
FLAGS
-Fcharacter
Uses character as the eld separator character (a space by default).
-f program
Searches for the patterns and performs the actions found in the le program.
DESCRIPTION
The nawk command provides a exible 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 ow in the actions.
Does not require any compiling of programs.
Pattern-matching and action statements can be specied either on the command line or in a pro-
gram le. In either case, nawk rst reads all matching and action statements, then reads a line of
input and compares it to each specied pattern. If the line matches a specied pattern, nawk per-
forms the specied 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 les in the order stated on the command line. If you specify a
lename as a - (dash) or do not specify a lename, 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 le 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 elds separated by spaces, tabs, or a eld 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.
527188-003 Hewlett-Packard Company 629