Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)
printf(1) OSS Shell and Utilities Reference Manual
Each conversion specification in the format argument has the following syntax:
1. A % (percent sign).
2. Zero or more options, which modify the meaning of the conversion specification. The
option characters and their meaning are as follows:
- The result of the conversion is left aligned within the field.
+ The result of a signed conversion always begins with a + (plus) or - (minus).
blank If the first character of a signed conversion is not a sign, a blank is prefixed 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
first digit of the result to be a 0 (zero). For x and X conversions, a nonzero
result has 0x or 0X prefixed 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 field 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 specified, the 0
(zero) option is ignored.
3. An optional decimal digit string that specifies the minimum field width. If the converted
value has fewer characters than the field width, the field is padded on the left to the
length specified by the field width. If the left-adjustment option is specified, the field 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 specifies:
• 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 significant 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 specification is reached. If the pre-
cision is omitted, all bytes until the first null character are printed.
7−34 Hewlett-Packard Company 527188-021