[-1c?
@(#)$Id: printf (AT&T Research) 2014-05-28 $
]
[+NAME?printf - write formatted output]
[+DESCRIPTION?\bprintf\b writes each \astring\a operand to standard output using \aformat\a to control the output format.]
[+?The \aformat\a operands supports the full range of ANSI C formatting specifiers plus the following additional specifiers:]{
[+%b?Each character in the \astring\a operand is processed specially as follows:]{
[+\\a?Alert character.]
[+\\b?Backspace character.]
[+\\c?Terminate output without appending newline. The remaining \astring\a operands are ignored.]
[+\\f?Formfeed character.]
[+\\n?Newline character.]
[+\\t?Tab character.]
[+\\v?Vertical tab character.]
[+\\\\?Backslash character.]
[+\\E?Escape character (ASCII octal 033).]
[+\\0\ax\a?The 8-bit character whose ASCII code is the 1-, 2-, or 3-digit octal number \ax\a.]
}
[+%q?Output \astring\a quoted in a manner that it can be read in by the shell to get back the same string.  However, empty strings resulting from missing \astring\a operands will not be quoted. When \bq\b is preceded by the alternative format specifier, \b#\b, the string is quoted in manner suitable as a field in a \b.csv\b format file.]
[+%B?Treat the argument as a variable name and output the value without converting it to a string.  This is most useful for variables of type \b-b\b.
[+%H?Output \astring\a with characters \b<\b, \b&\b, \b>\b, \b\"\b, and non-printable characters properly escaped for use in HTML and XML documents.  The alternate flag \b#\b formats the output for use as a URI.]
[+%P?Treat \astring\a as an extended regular expression and convert it to a shell pattern.]
[+%R?Treat \astring\a as an shell pattern expression and convert it to an extended regular expression.]
[+%T?Treat \astring\a as a date/time string and format it.  The \bT\b can be preceded by \b(\b\adformat\a\b)\b, where \adformat\a is a date format as defined by the \bdate\b command.  Values given as digits are interpreted the same way they are by the \btouch\b command.]
[+%Z?Output a byte whose value is \b0\b.]
[+%Q?Convert number of seconds to readable time.]
[+%p?Convert number to hexadecimal.]
\fextra\f
}
[+?The format modifier flag \bL\b can precede the width and/or precision specifiers for the \bc\b and \bs\b to cause the width and/or precision to be measured in character width rather than byte count.]
[+?When performing conversions of \astring\a to satisfy a numeric format specifier, if the first character of \astring\a is \b\"\b or \b'\b, then the value will be the numeric value in the underlying code set of the character following the \b\"\b or \b'\b.  Otherwise, \astring\a is treated like a shell arithmetic expression and evaluated.]
[+?If a \astring\a operand cannot be completely converted into a value appropriate for that format specifier, an error will occur, but remaining \astring\a operands will continue to be processed.]
[+?In addition to the format specifier extensions, the following extensions of ANSI-C are permitted in format specifiers:]{
[+-?The escape sequences \b\\E\b and \b\\e\b expand to the escape character which is octal \b033\b in ASCII.]
[+-?The escape sequence \b\\c\b\ax\a expands to Control-\ax\a.]
[+-?The escape sequence \b\\C[.\b\aname\a\b.]]\b expands to the collating element \aname\a.]
[+-?The escape sequence \b\\x{\b\ahex\a\b}\b expands to the character corresponding to the hexadecimal value \ahex\a.]
[+-?The escape sequence \b\\u[\b\ahex\a\b]]\b or \b\\u{\b\ahex\a\b}\b expands to the UTF-32 character corresponding to the unicode code point defined by the hexadecimal value \ahex\a. If the code point is not available in the current locale the escape sequence is treated as a literal sequence of characters.]
[+-?The escape sequence \b\\w[\b\ahex\a\b]]\b or \b\\w{\b\ahex\a\b}\b expands to the character corresponding to the (wchar_t) code point defined by the hexadecimal value \ahex\a in the current locale.]
[+-?The format modifier flag \b=\b can be used to center a field to a specified width.]
[+-?The format modifier flag \bL\b can be used with the \bc\b and \bs\b formats to treat precision as character width instead of byte count.]
[+-?The format modifier flag \b,\b can be used with \bd\b and \bf\b formats to cause group of digits.]
[+-?Each of the integral format specifiers can have a third modifier after width and precision that specifies the base of the conversion from 2 to 64.  In this case the \b#\b modifier will cause \abase\a\b#\b to be prepended to the value.]
[+-?The \b#\b modifier can be used with the \bd\b specifier when no base is specified cause the output to be written in units of \b1000\b with a suffix of one of \bk M G T P E\b.]
[+-?The \b#\b modifier can be used with the \bi\b specifier to cause the output to be written in units of \b1024\b with a suffix of one of \bKi Mi Gi Ti Pi Ei\b.]
}
[+?If there are more \astring\a operands than format specifiers, the \aformat\a string is reprocessed from the beginning.  If there are fewer \astring\a operands than format specifiers, then string specifiers will be treated as if empty strings were supplied, numeric conversions will be treated as if 0 were supplied, and time conversions will be treated as if \bnow\b were supplied.]
[+?\bprintf\b is equivalent to \bprint -f\b which allows additional options to be specified.]
[v]:[name?Put the output in the variable \aname\a instead of writing to standard output.]

format [string ...]

[+EXIT STATUS?]{
[+0?Successful completion.]
[+>0?An error occurred.]
}
[+SEE ALSO?\bdate\b(1), \bprint\b(1), \bread\b(1), \btouch\b(1)]
