HP-UX Reference (11i v3 07/02) - 1 User Commands N-Z (vol 2)
p
printf(1) printf(1)
If any internationalization variable contains an invalid setting, printf behaves as if all internationalization
variables are set to "C". See environ(5).
International Code Set Support
Single and multi-byte character code sets are supported.
RETURN VALUE
printf exits with one of the following values:
0 Successful completion.
>0 Errors occurred; the exit value is increased by one for each error that occurred up to a maximum
of 255.
DIAGNOSTICS
If an argument cannot be converted into a form suitable for the corresponding conversion specification, or
for any other reason cannot be correctly printed, a diagnostic message is printed to standard error, the
argument is output as a string form as it was given on the command line, and the exit value is incre-
mented.
EXAMPLES
The following command prints the number 123 in octal, hexadecimal and floating point formats in their
alternate form
printf "%#o, %#x, %#X, %#f, %#g, %#e\n" 123 123 123 123 123 123
resulting in the following output
0173, 0x7b, 0X7B, 123.000000, 123.000, 1.230000e+02
Print the outputs with their corresponding field widths and precision:
printf "%.6d, %10.6d, %.6f, %.6e, %.6s\n" 123 123 1.23 123.4 MoreThanSix
resulting in the following output
000123, 000123, 1.230000, 1.234000e+02, MoreTh
SEE ALSO
echo(1), printf(3S).
STANDARDS CONFORMANCE
printf: XPG4, POSIX.2
HP-UX 11i Version 3: February 2007 − 3 − Hewlett-Packard Company 145