Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

printf(1) OSS Shell and Utilities Reference Manual
leading character causes the eld width value to be padded with leading zeros.
An octal value for eld 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 specied, all characters up to the rst null character
are printed.
u Accepts an integer value and converts it to unsigned decimal notation. The pre-
cision species 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 eld width with a 0 (zero) as a
leading character causes the eld 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 species 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 eld width with a 0 (zero) as a leading character causes the eld
width value to be padded with leading zeros.
If the result of a conversion is wider than the eld width, the eld 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 specication.
RELATED INFORMATION
Commands: read(1).
Functions: printf(3).
736 Hewlett-Packard Company 527188-007