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

printf(1) OSS Shell and Utilities Reference Manual
Each conversion specication in the format argument has the following syntax:
1. A % (percent sign).
2. Zero or more options, which modify the meaning of the conversion specication. The
option characters and their meaning are as follows:
- The result of the conversion is left aligned within the eld.
+ The result of a signed conversion always begins with a + (plus) or - (minus).
blank If the rst character of a signed conversion is not a sign, a blank is prexed to
the result. If both the blank and + options appear, then the blank option is
ignored.
# The value is converted to an alternative form. For c, d, i, u, and s conversions,
the option has no effect. For o conversion, it increases the precision to force the
rst digit of the result to be a 0 (zero). For x and X conversions, a nonzero
result has 0x or 0X prexed to it, respectively. For e, E, f, g, and G conver-
sions, the result always contains a radix character, even if no digits follow the
radix character. For g and G conversions, trailing zeros are not removed from
the result as they usually are.
0 For d, i, o, u, x, X, e, E, f, g, and G conversions, leading zeros (following any
indication of sign or base) are used to pad to the eld width; no space padding
is performed. If the 0 (zero) and - options appear, the 0 (zero) option is
ignored. For d, i, o, u, x, and X conversions, if a precision is specied, the 0
(zero) option is ignored.
3. An optional decimal digit string that species the minimum eld width. If the converted
value has fewer characters than the eld width, the eld is padded on the left to the
length specied by the eld width. If the left-adjustment option is specied, the eld is
padded on the right.
4. An optional precision. The precision is a . (dot) followed by a decimal digit string. If no
precision is given, it is treated as 0 (zero). The precision species:
The minimum number of digits to appear for the d, i, o, u, x,orX conversions.
The number of digits to appear after the radix character for the e and f conver-
sions.
The maximum number of signicant digits for the g conversion.
The maximum number of bytes to be printed from a string in the s conversion.
5. A character that indicates the type of conversion to be applied, as follows:
% Performs no conversion. Prints a % (percent sign).
b Accepts a value as a string that may contain backslash-escape sequences.
Bytes from the converted string are printed until the end of the string or the
number of bytes indicated by the precision specication is reached. If the pre-
cision is omitted, all bytes until the rst null character are printed.
734 Hewlett-Packard Company 527188-007