printf.1 (95124) | printf.1 (95300) |
---|---|
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 --- 19 unchanged lines hidden (view full) --- 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)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 --- 19 unchanged lines hidden (view full) --- 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)printf.1 8.1 (Berkeley) 6/6/93 |
36.\" $FreeBSD: head/usr.bin/printf/printf.1 95124 2002-04-20 12:18:28Z charnier $ | 36.\" $FreeBSD: head/usr.bin/printf/printf.1 95300 2002-04-23 02:56:16Z jmallett $ |
37.\" 38.Dd June 6, 1993 39.Dt PRINTF 1 40.Os 41.Sh NAME 42.Nm printf 43.Nd formatted output 44.Sh SYNOPSIS --- 12 unchanged lines hidden (view full) --- 57are converted and copied to the standard output, and format specifications, 58each of which causes printing of the next successive 59.Ar argument . 60.Pp 61The 62.Ar arguments 63after the first are treated as strings if the corresponding format is 64either | 37.\" 38.Dd June 6, 1993 39.Dt PRINTF 1 40.Os 41.Sh NAME 42.Nm printf 43.Nd formatted output 44.Sh SYNOPSIS --- 12 unchanged lines hidden (view full) --- 57are converted and copied to the standard output, and format specifications, 58each of which causes printing of the next successive 59.Ar argument . 60.Pp 61The 62.Ar arguments 63after the first are treated as strings if the corresponding format is 64either |
65.Cm c | 65.Cm c , 66.Cm b |
66or 67.Cm s ; 68otherwise it is evaluated as a C constant, with the following extensions: 69.Pp 70.Bl -bullet -offset indent -compact 71.It 72A leading plus or minus sign is allowed. 73.It | 67or 68.Cm s ; 69otherwise it is evaluated as a C constant, with the following extensions: 70.Pp 71.Bl -bullet -offset indent -compact 72.It 73A leading plus or minus sign is allowed. 74.It |
74If the leading character is a single or double quote, or not a digit, 75plus, or minus sign, the value is the ASCII code of the next character. | 75If the leading character is a single or double quote the value is the ASCII 76code of the next character. |
76.El 77.Pp 78The format string is reused as often as necessary to satisfy the 79.Ar arguments . 80Any extra format specifications are evaluated with zero or the null 81string. 82.Pp 83Character escape sequences are in backslash notation as defined in the | 77.El 78.Pp 79The format string is reused as often as necessary to satisfy the 80.Ar arguments . 81Any extra format specifications are evaluated with zero or the null 82string. 83.Pp 84Character escape sequences are in backslash notation as defined in the |
84.St -ansiC . | 85.St -ansiC , 86with extensions. |
85The characters and their meanings 86are as follows: 87.Pp 88.Bl -tag -width Ds -offset indent -compact 89.It Cm \ea 90Write a <bell> character. 91.It Cm \eb 92Write a <backspace> character. | 87The characters and their meanings 88are as follows: 89.Pp 90.Bl -tag -width Ds -offset indent -compact 91.It Cm \ea 92Write a <bell> character. 93.It Cm \eb 94Write a <backspace> character. |
95.It Cm \ec 96Ignore remaining characters in this string. |
|
93.It Cm \ef 94Write a <form-feed> character. 95.It Cm \en 96Write a <new-line> character. 97.It Cm \er 98Write a <carriage return> character. 99.It Cm \et 100Write a <tab> character. 101.It Cm \ev 102Write a <vertical tab> character. 103.It Cm \e\' 104Write a <single quote> character. 105.It Cm \e\e 106Write a backslash character. 107.It Cm \e Ns Ar num | 97.It Cm \ef 98Write a <form-feed> character. 99.It Cm \en 100Write a <new-line> character. 101.It Cm \er 102Write a <carriage return> character. 103.It Cm \et 104Write a <tab> character. 105.It Cm \ev 106Write a <vertical tab> character. 107.It Cm \e\' 108Write a <single quote> character. 109.It Cm \e\e 110Write a backslash character. 111.It Cm \e Ns Ar num |
112.It Cm \e0 Ns Ar num |
|
108Write an 8-bit character whose 109.Tn ASCII 110value is the 1-, 2-, or 3-digit 111octal number 112.Ar num . 113.El 114.Pp 115Each format specification is introduced by the percent character --- 66 unchanged lines hidden (view full) --- 182.Cm e 183and 184.Cm f 185formats, or the maximum number of characters to be printed 186from a string; if the digit string is missing, the precision is treated 187as zero; 188.It Format: 189A character which indicates the type of format to use (one of | 113Write an 8-bit character whose 114.Tn ASCII 115value is the 1-, 2-, or 3-digit 116octal number 117.Ar num . 118.El 119.Pp 120Each format specification is introduced by the percent character --- 66 unchanged lines hidden (view full) --- 187.Cm e 188and 189.Cm f 190formats, or the maximum number of characters to be printed 191from a string; if the digit string is missing, the precision is treated 192as zero; 193.It Format: 194A character which indicates the type of format to use (one of |
190.Cm diouxXfwEgGcs ) . | 195.Cm diouxXfwEgGcsb ) . |
191.El 192.Pp 193A field width or precision may be 194.Sq Cm \&* 195instead of a digit string. 196In this case an 197.Ar argument 198supplies the field width or precision. --- 40 unchanged lines hidden (view full) --- 239.Ar argument 240is printed. 241.It Cm s 242Characters from the string 243.Ar argument 244are printed until the end is reached or until the number of characters 245indicated by the precision specification is reached; however if the 246precision is 0 or missing, all characters in the string are printed. | 196.El 197.Pp 198A field width or precision may be 199.Sq Cm \&* 200instead of a digit string. 201In this case an 202.Ar argument 203supplies the field width or precision. --- 40 unchanged lines hidden (view full) --- 244.Ar argument 245is printed. 246.It Cm s 247Characters from the string 248.Ar argument 249are printed until the end is reached or until the number of characters 250indicated by the precision specification is reached; however if the 251precision is 0 or missing, all characters in the string are printed. |
252.It Cm b 253As for 254.Cm s , 255but interpret character escapes in backslash notation in the string 256.Ar argument . |
|
247.It Cm \&% 248Print a `%'; no argument is used. 249.El 250.Pp 251The decimal point 252character is defined in the program's locale (category 253.Dv LC_NUMERIC ) . 254.Pp 255In no case does a non-existent or small field width cause truncation of 256a field; padding takes place only if the specified field width exceeds 257the actual width. 258.Sh DIAGNOSTICS 259.Ex -std | 257.It Cm \&% 258Print a `%'; no argument is used. 259.El 260.Pp 261The decimal point 262character is defined in the program's locale (category 263.Dv LC_NUMERIC ) . 264.Pp 265In no case does a non-existent or small field width cause truncation of 266a field; padding takes place only if the specified field width exceeds 267the actual width. 268.Sh DIAGNOSTICS 269.Ex -std |
270.Sh COMPATIBILITY 271The traditional 272.Bx 273behavior of converting arguments of numeric formats not beginning 274with a digit to the ASCII code of the first characer is not supported. |
|
260.Sh SEE ALSO | 275.Sh SEE ALSO |
276.Xr echo 1 , |
|
261.Xr printf 3 | 277.Xr printf 3 |
278.Sh STANDARDS 279The 280.Nm 281command is expected to be compatible with the 282.St -p1003.2 283specification. |
|
262.Sh HISTORY 263The 264.Nm 265command appeared in 266.Bx 4.3 Reno . 267It is modeled 268after the standard library function, 269.Xr printf 3 . --- 14 unchanged lines hidden --- | 284.Sh HISTORY 285The 286.Nm 287command appeared in 288.Bx 4.3 Reno . 289It is modeled 290after the standard library function, 291.Xr printf 3 . --- 14 unchanged lines hidden --- |