PRINTF(1P) POSIX Programmer's Manual PRINTF(1P)
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond-
ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
NAME
printf -- write formatted output
SYNOPSIS
printf format [argument...]
DESCRIPTION
The printf utility shall write formatted operands to the standard output. The argument operands shall be formatted under control of the
format operand.
OPTIONS
None.
OPERANDS
The following operands shall be supported:
format A string describing the format to use to write the remaining operands. See the EXTENDED DESCRIPTION section.
argument The strings to be written to standard output, under the control of format. See the EXTENDED DESCRIPTION section.
STDIN
Not used.
INPUT FILES
None.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of printf:
LANG Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
POSIX.1-2008, Section 8.2, Internationalization Variables the precedence of internationalization variables used to determine the
values of locale categories.)
LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables.
LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed
to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
LC_NUMERIC
Determine the locale for numeric formatting. It shall affect the format of numbers written using the e, E, f, g, and G conversion
specifier characters (if supported).
NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES.
ASYNCHRONOUS EVENTS
Default.
STDOUT
See the EXTENDED DESCRIPTION section.
STDERR
The standard error shall be used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
The format operand shall be used as the format string described in the Base Definitions volume of POSIX.1-2008, Chapter 5, File Format
Notation with the following exceptions:
1. A <space> in the format string, in any context other than a flag of a conversion specification, shall be treated as an ordinary charac-
ter that is copied to the output.
2. A '' character in the format string shall be treated as a '' character, not as a <space>.
3. In addition to the escape sequences shown in the Base Definitions volume of POSIX.1-2008, Chapter 5, File Format Notation ('\', 'a',
'', 'f', '
', '
', ' ', 'v'), "ddd", where ddd is a one, two, or three-digit octal number, shall be written as a byte with the
numeric value specified by the octal number.
4. The implementation shall not precede or follow output from the d or u conversion specifiers with <blank> characters not specified by
the format operand.
5. The implementation shall not precede output from the o conversion specifier with zeros not specified by the format operand.
6. The a, A, e, E, f, F, g, and G conversion specifiers need not be supported.
7. An additional conversion specifier character, b, shall be supported as follows. The argument shall be taken to be a string that may
contain <backslash>-escape sequences. The following <backslash>-escape sequences shall be supported:
-- The escape sequences listed in the Base Definitions volume of POSIX.1-2008, Chapter 5, File Format Notation ('\', 'a', '',
'f', '
', '
', ' ', 'v'), which shall be converted to the characters they represent
-- "