printf.1 (222418) | printf.1 (222421) |
---|---|
1.\" Copyright (c) 1989, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions --- 15 unchanged lines hidden (view full) --- 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)printf.1 8.1 (Berkeley) 6/6/93 | 1.\" Copyright (c) 1989, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions --- 15 unchanged lines hidden (view full) --- 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)printf.1 8.1 (Berkeley) 6/6/93 |
32.\" $FreeBSD: head/usr.bin/printf/printf.1 222418 2011-05-28 11:37:47Z jilles $ | 32.\" $FreeBSD: head/usr.bin/printf/printf.1 222421 2011-05-28 14:32:47Z jilles $ |
33.\" 34.Dd May 28, 2011 35.Dt PRINTF 1 36.Os 37.Sh NAME 38.Nm printf 39.Nd formatted output 40.Sh SYNOPSIS --- 125 unchanged lines hidden (view full) --- 166.It Cm \&0 167A zero `0' character indicating that zero-padding should be used 168rather than blank-padding. 169A `\-' overrides a `0' if both are used; 170.El 171.It "Field Width:" 172An optional digit string specifying a 173.Em field width ; | 33.\" 34.Dd May 28, 2011 35.Dt PRINTF 1 36.Os 37.Sh NAME 38.Nm printf 39.Nd formatted output 40.Sh SYNOPSIS --- 125 unchanged lines hidden (view full) --- 166.It Cm \&0 167A zero `0' character indicating that zero-padding should be used 168rather than blank-padding. 169A `\-' overrides a `0' if both are used; 170.El 171.It "Field Width:" 172An optional digit string specifying a 173.Em field width ; |
174if the output string has fewer characters than the field width it will | 174if the output string has fewer bytes than the field width it will |
175be blank-padded on the left (or right, if the left-adjustment indicator 176has been given) to make up the field width (note that a leading zero 177is a flag, but an embedded zero is part of a field width); 178.It Precision: 179An optional period, 180.Sq Cm \&.\& , 181followed by an optional digit string giving a 182.Em precision 183which specifies the number of digits to appear after the decimal point, 184for 185.Cm e 186and 187.Cm f | 175be blank-padded on the left (or right, if the left-adjustment indicator 176has been given) to make up the field width (note that a leading zero 177is a flag, but an embedded zero is part of a field width); 178.It Precision: 179An optional period, 180.Sq Cm \&.\& , 181followed by an optional digit string giving a 182.Em precision 183which specifies the number of digits to appear after the decimal point, 184for 185.Cm e 186and 187.Cm f |
188formats, or the maximum number of characters to be printed | 188formats, or the maximum number of bytes to be printed |
189from a string; if the digit string is missing, the precision is treated 190as zero; 191.It Format: 192A character which indicates the type of format to use (one of 193.Cm diouxXfFeEgGaAcsb ) . 194The uppercase formats differ from their lowercase counterparts only in 195that the output of the former is entirely in uppercase. 196The floating-point format specifiers --- 69 unchanged lines hidden (view full) --- 266when the precision is missing, enough digits are produced to convey 267the argument's exact double-precision floating-point representation. 268The values \*[If] and \*[Na] are printed as 269.Ql inf 270and 271.Ql nan , 272respectively. 273.It Cm c | 189from a string; if the digit string is missing, the precision is treated 190as zero; 191.It Format: 192A character which indicates the type of format to use (one of 193.Cm diouxXfFeEgGaAcsb ) . 194The uppercase formats differ from their lowercase counterparts only in 195that the output of the former is entirely in uppercase. 196The floating-point format specifiers --- 69 unchanged lines hidden (view full) --- 266when the precision is missing, enough digits are produced to convey 267the argument's exact double-precision floating-point representation. 268The values \*[If] and \*[Na] are printed as 269.Ql inf 270and 271.Ql nan , 272respectively. 273.It Cm c |
274The first character of | 274The first byte of |
275.Ar argument 276is printed. 277.It Cm s | 275.Ar argument 276is printed. 277.It Cm s |
278Characters from the string | 278Bytes from the string |
279.Ar argument | 279.Ar argument |
280are printed until the end is reached or until the number of characters | 280are printed until the end is reached or until the number of bytes |
281indicated by the precision specification is reached; however if the | 281indicated by the precision specification is reached; however if the |
282precision is 0 or missing, all characters in the string are printed. | 282precision is 0 or missing, the string is printed entirely. |
283.It Cm b 284As for 285.Cm s , 286but interpret character escapes in backslash notation in the string 287.Ar argument . 288The permitted escape sequences are slightly different in that 289octal escapes are 290.Cm \e0 Ns Ar num --- 50 unchanged lines hidden (view full) --- 341hexadecimal character constants were deliberately not provided. 342.Pp 343Trying to print a dash ("-") as the first character causes 344.Nm 345to interpret the dash as a program argument. 346.Nm -- 347must be used before 348.Ar format . | 283.It Cm b 284As for 285.Cm s , 286but interpret character escapes in backslash notation in the string 287.Ar argument . 288The permitted escape sequences are slightly different in that 289octal escapes are 290.Cm \e0 Ns Ar num --- 50 unchanged lines hidden (view full) --- 341hexadecimal character constants were deliberately not provided. 342.Pp 343Trying to print a dash ("-") as the first character causes 344.Nm 345to interpret the dash as a program argument. 346.Nm -- 347must be used before 348.Ar format . |
349.Pp 350If the locale contains multibyte characters 351(such as UTF-8), 352the 353.Cm c 354format and 355.Cm b 356and 357.Cm s 358formats with a precision 359may not operate as expected. |
|
349.Sh BUGS 350Since the floating point numbers are translated from 351.Tn ASCII 352to floating-point and 353then back again, floating-point precision may be lost. 354(By default, the number is translated to an IEEE-754 double-precision 355value before being printed. 356The --- 12 unchanged lines hidden --- | 360.Sh BUGS 361Since the floating point numbers are translated from 362.Tn ASCII 363to floating-point and 364then back again, floating-point precision may be lost. 365(By default, the number is translated to an IEEE-754 double-precision 366value before being printed. 367The --- 12 unchanged lines hidden --- |