Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
printf(1) OSS Shell and Utilities Reference Manual
leading character causes the field width value to be padded with leading zeros.
An octal value for field width is not implied.
s Accepts a value as a string, and bytes from the string are printed until the end
of the string is encountered or the number of bytes indicated by the precision is
reached. If no precision is specified, all characters up to the first null character
are printed.
u Accepts an integer value and converts it to unsigned decimal notation. The pre-
cision specifies the minimum number of digits to appear. If the value being
converted can be represented in fewer digits, it is expanded with leading zeros.
The default precision is 1. The result of converting a 0 (zero) value with a pre-
cision of 0 (zero) is a null string. Specifying a field width with a 0 (zero) as a
leading character causes the field width value to be padded with leading zeros.
x, X Accepts an integer value and converts it to unsigned hexadecimal notation.
The letters abcdef are used for the x conversion, and the letters ABCDEF are
used for the X conversion. The precision specifies the minimum number of
digits to appear. If the value being converted can be represented in fewer
digits, it is expanded with leading zeros. The default precision is 1. The result
of converting a 0 (zero) value with a precision of 0 (zero) is a null string.
Specifying a field width with a 0 (zero) as a leading character causes the field
width value to be padded with leading zeros.
If the result of a conversion is wider than the field width, the field is expanded to contain
the converted result. No truncation occurs. However, a small precision may cause trunca-
tion on the right.
EXAMPLES
The following command
printf "%5d%4d\n" 1 21 321 4321 54321
produces the following output:
121
3214321
54321 0
The format argument is used three times to print all of the given strings. The 0 (zero) is supplied
by the printf command to satisfy the last %4d conversion specification.
RELATED INFORMATION
Commands: read(1).
Functions: printf(3).
7−36 Hewlett-Packard Company 527188-003