Output separators
The output field separator and record separator
are held in the built-in variables
OFS
and
ORS.
Initially,
OFS
is set to a single blank
and
ORS
to a single newline,
but these values can be changed at any time.
For example, the following
program prints the first and second fields of each record
with a colon between the fields and two newlines after the second field:
BEGIN { OFS = ":"; ORS = "\n\n" }
{ print $1, $2 }
Notice that
{ print $1 $2 }
prints the first and second fields with no
intervening output field separator
because
$1 $2
is a string consisting of the concatenation
of the first two fields.
Next topic:
The printf statement
Previous topic:
The print statement
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004