MPE/iX Shell and Utilities Reference Manual, Vol 2

printf(1) MPE/iX Shell and Utilities printf(1)
NAME
printf — display a formatted string
SYNOPSIS
printf format [argument ...]
DESCRIPTION
printf writes the argument operand(s) to standard output, formatted according to the format
operand.
format is a format string composed of conversion specifications that convert and add the next
argument to the output. These conversions are similar to those used by the
ANSI C standard.
Conversion specifications have the form
%[flag][width][.precision][char]
where flag is one of the following:
- left justifies the field; default is right justification.
+ always prefixes a signed value with a sign (+ or -).
space reserves a character position at the start of the string for the minus sign (for negative
numbers) or a space (for positive numbers). If both space and - appear as flags,
the space flag is ignored.
# prefixes octal values with 0 and hexadecimal values with 0x or 0X. For floating
point values, this forces the decimal point to be displayed, even if no characters fol-
low it.
0 pads numeric values with leading zeros. If both 0 and - appear as flags, the 0 flag
is ignored.
width is the minimum field width of the output field. If the converted value is shorter than the
minimum width, printf pads it with spaces or zeros.
In a string, precision is the maximum number of characters to be printed from the string; in a
number, the precision is the number of digits to be printed to right of the decimal point in a
floating point value. width or precision may be specified as *, in which case the value is read
from the next argument, which must be an integer. For example:
printf "%*.*d\n" 20 10 200
is equivalent to
printf "%20.10d\n" 200
Commands and Utilities 1-439