HP-UX Reference (11i v2 04/09) - 1 User Commands N-Z (vol 2)
p
printf(1) printf(1)
set to the empty string, a default of "C" (see lang(5)) is used instead of
LANG.
If any internationalization variable contains an invalid setting, printf behaves as if all internationaliza-
tion 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 max-
imum 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 2: September 2004 − 3 − Hewlett-Packard Company Section 1−−751