19b50d902SRodney W. Grimes.\" Copyright (c) 1989, 1990, 1993 29b50d902SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 39b50d902SRodney W. Grimes.\" 49b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 59b50d902SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc. 69b50d902SRodney W. Grimes.\" 79b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 89b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions 99b50d902SRodney W. Grimes.\" are met: 109b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 119b50d902SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 129b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 139b50d902SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 149b50d902SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 15fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 169b50d902SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 179b50d902SRodney W. Grimes.\" without specific prior written permission. 189b50d902SRodney W. Grimes.\" 199b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 209b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 219b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 229b50d902SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 239b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 249b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 259b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 269b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 279b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 289b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 299b50d902SRodney W. Grimes.\" SUCH DAMAGE. 309b50d902SRodney W. Grimes.\" 319b50d902SRodney W. Grimes.\" @(#)printf.1 8.1 (Berkeley) 6/6/93 329b50d902SRodney W. Grimes.\" 33*5dbd4b8eSFernando Apesteguía.Dd July 1, 2020 349b50d902SRodney W. Grimes.Dt PRINTF 1 359b50d902SRodney W. Grimes.Os 369b50d902SRodney W. Grimes.Sh NAME 379b50d902SRodney W. Grimes.Nm printf 389b50d902SRodney W. Grimes.Nd formatted output 399b50d902SRodney W. Grimes.Sh SYNOPSIS 4069d85135SPhilippe Charnier.Nm 4169d85135SPhilippe Charnier.Ar format Op Ar arguments ... 429b50d902SRodney W. Grimes.Sh DESCRIPTION 43e8937ba0SPhilippe CharnierThe 44e8937ba0SPhilippe Charnier.Nm 45e8937ba0SPhilippe Charnierutility formats and prints its arguments, after the first, under control 469b50d902SRodney W. Grimesof the 479b50d902SRodney W. Grimes.Ar format . 489b50d902SRodney W. GrimesThe 499b50d902SRodney W. Grimes.Ar format 509b50d902SRodney W. Grimesis a character string which contains three types of objects: plain characters, 519b50d902SRodney W. Grimeswhich are simply copied to standard output, character escape sequences which 529b50d902SRodney W. Grimesare converted and copied to the standard output, and format specifications, 539b50d902SRodney W. Grimeseach of which causes printing of the next successive 549b50d902SRodney W. Grimes.Ar argument . 559b50d902SRodney W. Grimes.Pp 569b50d902SRodney W. GrimesThe 579b50d902SRodney W. Grimes.Ar arguments 589b50d902SRodney W. Grimesafter the first are treated as strings if the corresponding format is 599b50d902SRodney W. Grimeseither 603a0f91d5SRuslan Ermilov.Cm c , b 619b50d902SRodney W. Grimesor 629b50d902SRodney W. Grimes.Cm s ; 639b50d902SRodney W. Grimesotherwise it is evaluated as a C constant, with the following extensions: 649b50d902SRodney W. Grimes.Pp 659b50d902SRodney W. Grimes.Bl -bullet -offset indent -compact 669b50d902SRodney W. Grimes.It 679b50d902SRodney W. GrimesA leading plus or minus sign is allowed. 689b50d902SRodney W. Grimes.It 693a0f91d5SRuslan ErmilovIf the leading character is a single or double quote, the value is the 7098102dabSJilles Tjoelkercharacter code of the next character. 719b50d902SRodney W. Grimes.El 729b50d902SRodney W. Grimes.Pp 739b50d902SRodney W. GrimesThe format string is reused as often as necessary to satisfy the 749b50d902SRodney W. Grimes.Ar arguments . 759b50d902SRodney W. GrimesAny extra format specifications are evaluated with zero or the null 769b50d902SRodney W. Grimesstring. 779b50d902SRodney W. Grimes.Pp 789b50d902SRodney W. GrimesCharacter escape sequences are in backslash notation as defined in the 79ab5a295bSJuli Mallett.St -ansiC , 80ab5a295bSJuli Mallettwith extensions. 819b50d902SRodney W. GrimesThe characters and their meanings 829b50d902SRodney W. Grimesare as follows: 839b88faecSRuslan Ermilov.Pp 849b88faecSRuslan Ermilov.Bl -tag -width Ds -offset indent -compact 859b50d902SRodney W. Grimes.It Cm \ea 869b50d902SRodney W. GrimesWrite a <bell> character. 879b50d902SRodney W. Grimes.It Cm \eb 889b50d902SRodney W. GrimesWrite a <backspace> character. 899b50d902SRodney W. Grimes.It Cm \ef 909b50d902SRodney W. GrimesWrite a <form-feed> character. 919b50d902SRodney W. Grimes.It Cm \en 929b50d902SRodney W. GrimesWrite a <new-line> character. 939b50d902SRodney W. Grimes.It Cm \er 949b50d902SRodney W. GrimesWrite a <carriage return> character. 959b50d902SRodney W. Grimes.It Cm \et 969b50d902SRodney W. GrimesWrite a <tab> character. 979b50d902SRodney W. Grimes.It Cm \ev 989b50d902SRodney W. GrimesWrite a <vertical tab> character. 999b50d902SRodney W. Grimes.It Cm \e\' 1009b50d902SRodney W. GrimesWrite a <single quote> character. 1019b50d902SRodney W. Grimes.It Cm \e\e 1029b50d902SRodney W. GrimesWrite a backslash character. 1039b50d902SRodney W. Grimes.It Cm \e Ns Ar num 1043cf53e85SJilles TjoelkerWrite a byte whose 1059b50d902SRodney W. Grimesvalue is the 1-, 2-, or 3-digit 1069b50d902SRodney W. Grimesoctal number 1079b50d902SRodney W. Grimes.Ar num . 1083cf53e85SJilles TjoelkerMultibyte characters can be constructed using multiple 1093cf53e85SJilles Tjoelker.Cm \e Ns Ar num 1103cf53e85SJilles Tjoelkersequences. 1119b50d902SRodney W. Grimes.El 1129b50d902SRodney W. Grimes.Pp 1139b50d902SRodney W. GrimesEach format specification is introduced by the percent character 1149b50d902SRodney W. Grimes(``%''). 1159b50d902SRodney W. GrimesThe remainder of the format specification includes, 1169b50d902SRodney W. Grimesin the following order: 1179b50d902SRodney W. Grimes.Bl -tag -width Ds 1189b50d902SRodney W. Grimes.It "Zero or more of the following flags:" 1199b50d902SRodney W. Grimes.Bl -tag -width Ds 1209b50d902SRodney W. Grimes.It Cm # 1219b50d902SRodney W. GrimesA `#' character 1229b50d902SRodney W. Grimesspecifying that the value should be printed in an ``alternate form''. 1239b50d902SRodney W. GrimesFor 1248a906b23SJilles Tjoelker.Cm b , c , d , s 1259b50d902SRodney W. Grimesand 1268a906b23SJilles Tjoelker.Cm u 1276a3e8b0aSRuslan Ermilovformats, this option has no effect. 1286a3e8b0aSRuslan ErmilovFor the 1299b50d902SRodney W. Grimes.Cm o 1309b50d902SRodney W. Grimesformats the precision of the number is increased to force the first 1316a3e8b0aSRuslan Ermilovcharacter of the output string to a zero. 1326a3e8b0aSRuslan ErmilovFor the 1339b50d902SRodney W. Grimes.Cm x 1349b50d902SRodney W. Grimes.Pq Cm X 1359b50d902SRodney W. Grimesformat, a non-zero result has the string 1369b50d902SRodney W. Grimes.Li 0x 1379b50d902SRodney W. Grimes.Pq Li 0X 1386a3e8b0aSRuslan Ermilovprepended to it. 1396a3e8b0aSRuslan ErmilovFor 1408a906b23SJilles Tjoelker.Cm a , A , e , E , f , F , g 1419b50d902SRodney W. Grimesand 1428a906b23SJilles Tjoelker.Cm G 1439b50d902SRodney W. Grimesformats, the result will always contain a decimal point, even if no 1449b50d902SRodney W. Grimesdigits follow the point (normally, a decimal point only appears in the 1456a3e8b0aSRuslan Ermilovresults of those formats if a digit follows the decimal point). 1466a3e8b0aSRuslan ErmilovFor 1479b50d902SRodney W. Grimes.Cm g 1489b50d902SRodney W. Grimesand 1499b50d902SRodney W. Grimes.Cm G 1509b50d902SRodney W. Grimesformats, trailing zeros are not removed from the result as they 1519b50d902SRodney W. Grimeswould otherwise be; 1529b50d902SRodney W. Grimes.It Cm \&\- 1539b50d902SRodney W. GrimesA minus sign `\-' which specifies 1549b50d902SRodney W. Grimes.Em left adjustment 1559b50d902SRodney W. Grimesof the output in the indicated field; 1569b50d902SRodney W. Grimes.It Cm \&+ 1579b50d902SRodney W. GrimesA `+' character specifying that there should always be 1589b50d902SRodney W. Grimesa sign placed before the number when using signed formats. 1599b50d902SRodney W. Grimes.It Sq \&\ \& 1609b50d902SRodney W. GrimesA space specifying that a blank should be left before a positive number 1616a3e8b0aSRuslan Ermilovfor a signed format. 1626a3e8b0aSRuslan ErmilovA `+' overrides a space if both are used; 1639b50d902SRodney W. Grimes.It Cm \&0 1649b50d902SRodney W. GrimesA zero `0' character indicating that zero-padding should be used 1656a3e8b0aSRuslan Ermilovrather than blank-padding. 1666a3e8b0aSRuslan ErmilovA `\-' overrides a `0' if both are used; 1679b50d902SRodney W. Grimes.El 1689b50d902SRodney W. Grimes.It "Field Width:" 1699b50d902SRodney W. GrimesAn optional digit string specifying a 1709b50d902SRodney W. Grimes.Em field width ; 17127a43b2eSJilles Tjoelkerif the output string has fewer bytes than the field width it will 1729b50d902SRodney W. Grimesbe blank-padded on the left (or right, if the left-adjustment indicator 1739b50d902SRodney W. Grimeshas been given) to make up the field width (note that a leading zero 1749b50d902SRodney W. Grimesis a flag, but an embedded zero is part of a field width); 1759b50d902SRodney W. Grimes.It Precision: 1769b50d902SRodney W. GrimesAn optional period, 1779b50d902SRodney W. Grimes.Sq Cm \&.\& , 1789b50d902SRodney W. Grimesfollowed by an optional digit string giving a 1799b50d902SRodney W. Grimes.Em precision 1809b50d902SRodney W. Grimeswhich specifies the number of digits to appear after the decimal point, 1819b50d902SRodney W. Grimesfor 1829b50d902SRodney W. Grimes.Cm e 1839b50d902SRodney W. Grimesand 1849b50d902SRodney W. Grimes.Cm f 18527a43b2eSJilles Tjoelkerformats, or the maximum number of bytes to be printed 1869b50d902SRodney W. Grimesfrom a string; if the digit string is missing, the precision is treated 1879b50d902SRodney W. Grimesas zero; 1889b50d902SRodney W. Grimes.It Format: 1899b50d902SRodney W. GrimesA character which indicates the type of format to use (one of 19008cdb7cdSDavid Schultz.Cm diouxXfFeEgGaAcsb ) . 19108cdb7cdSDavid SchultzThe uppercase formats differ from their lowercase counterparts only in 192939e953eSDavid Schultzthat the output of the former is entirely in uppercase. 193fd757c50SDavid SchultzThe floating-point format specifiers 19439c59153SRuslan Ermilov.Pq Cm fFeEgGaA 195fd757c50SDavid Schultzmay be prefixed by an 196fd757c50SDavid Schultz.Cm L 197fd757c50SDavid Schultzto request that additional precision be used, if available. 1989b50d902SRodney W. Grimes.El 1999b50d902SRodney W. Grimes.Pp 2009b50d902SRodney W. GrimesA field width or precision may be 2019b50d902SRodney W. Grimes.Sq Cm \&* 2029b50d902SRodney W. Grimesinstead of a digit string. 2039b50d902SRodney W. GrimesIn this case an 2049b50d902SRodney W. Grimes.Ar argument 2059b50d902SRodney W. Grimessupplies the field width or precision. 2069b50d902SRodney W. Grimes.Pp 2079b50d902SRodney W. GrimesThe format characters and their meanings are: 2089b50d902SRodney W. Grimes.Bl -tag -width Fl 2099b50d902SRodney W. Grimes.It Cm diouXx 2109b50d902SRodney W. GrimesThe 2119b50d902SRodney W. Grimes.Ar argument 212457788f8SMike Pritchardis printed as a signed decimal (d or i), unsigned octal, unsigned decimal, 2139b50d902SRodney W. Grimesor unsigned hexadecimal (X or x), respectively. 21408cdb7cdSDavid Schultz.It Cm fF 2159b50d902SRodney W. GrimesThe 2169b50d902SRodney W. Grimes.Ar argument 2179b50d902SRodney W. Grimesis printed in the style `[\-]ddd.ddd' where the number of d's 2189b50d902SRodney W. Grimesafter the decimal point is equal to the precision specification for 2199b50d902SRodney W. Grimesthe argument. 2209b50d902SRodney W. GrimesIf the precision is missing, 6 digits are given; if the precision 22149776176SChris Costellois explicitly 0, no digits and no decimal point are printed. 22208cdb7cdSDavid SchultzThe values \*[If] and \*[Na] are printed as 22308cdb7cdSDavid Schultz.Ql inf 22408cdb7cdSDavid Schultzand 22508cdb7cdSDavid Schultz.Ql nan , 22608cdb7cdSDavid Schultzrespectively. 2279b50d902SRodney W. Grimes.It Cm eE 2289b50d902SRodney W. GrimesThe 2299b50d902SRodney W. Grimes.Ar argument 2309b50d902SRodney W. Grimesis printed in the style 2319b50d902SRodney W. Grimes.Cm e 2329b88faecSRuslan Ermilov.Sm off 2339b88faecSRuslan Ermilov.Sq Op - Ar d.ddd No \(+- Ar dd 2349b88faecSRuslan Ermilov.Sm on 2359b50d902SRodney W. Grimeswhere there 2369b50d902SRodney W. Grimesis one digit before the decimal point and the number after is equal to 2379b50d902SRodney W. Grimesthe precision specification for the argument; when the precision is 2389b50d902SRodney W. Grimesmissing, 6 digits are produced. 23908cdb7cdSDavid SchultzThe values \*[If] and \*[Na] are printed as 24008cdb7cdSDavid Schultz.Ql inf 24108cdb7cdSDavid Schultzand 24208cdb7cdSDavid Schultz.Ql nan , 24308cdb7cdSDavid Schultzrespectively. 2449b50d902SRodney W. Grimes.It Cm gG 2459b50d902SRodney W. GrimesThe 2469b50d902SRodney W. Grimes.Ar argument 2479b50d902SRodney W. Grimesis printed in style 2489b50d902SRodney W. Grimes.Cm f 24908cdb7cdSDavid Schultz.Pq Cm F 2509b50d902SRodney W. Grimesor in style 2519b50d902SRodney W. Grimes.Cm e 2529b50d902SRodney W. Grimes.Pq Cm E 2539b50d902SRodney W. Grimeswhichever gives full precision in minimum space. 25408cdb7cdSDavid Schultz.It Cm aA 25508cdb7cdSDavid SchultzThe 25608cdb7cdSDavid Schultz.Ar argument 25708cdb7cdSDavid Schultzis printed in style 25808cdb7cdSDavid Schultz.Sm off 25908cdb7cdSDavid Schultz.Sq Op - Ar h.hhh No \(+- Li p Ar d 26008cdb7cdSDavid Schultz.Sm on 26108cdb7cdSDavid Schultzwhere there is one digit before the hexadecimal point and the number 26208cdb7cdSDavid Schultzafter is equal to the precision specification for the argument; 26308cdb7cdSDavid Schultzwhen the precision is missing, enough digits are produced to convey 26408cdb7cdSDavid Schultzthe argument's exact double-precision floating-point representation. 26508cdb7cdSDavid SchultzThe values \*[If] and \*[Na] are printed as 26608cdb7cdSDavid Schultz.Ql inf 26708cdb7cdSDavid Schultzand 26808cdb7cdSDavid Schultz.Ql nan , 26908cdb7cdSDavid Schultzrespectively. 2709b50d902SRodney W. Grimes.It Cm c 27127a43b2eSJilles TjoelkerThe first byte of 2729b50d902SRodney W. Grimes.Ar argument 2739b50d902SRodney W. Grimesis printed. 2749b50d902SRodney W. Grimes.It Cm s 27527a43b2eSJilles TjoelkerBytes from the string 2769b50d902SRodney W. Grimes.Ar argument 27727a43b2eSJilles Tjoelkerare printed until the end is reached or until the number of bytes 2789b50d902SRodney W. Grimesindicated by the precision specification is reached; however if the 27927a43b2eSJilles Tjoelkerprecision is 0 or missing, the string is printed entirely. 280ab5a295bSJuli Mallett.It Cm b 281ab5a295bSJuli MallettAs for 282ab5a295bSJuli Mallett.Cm s , 283ab5a295bSJuli Mallettbut interpret character escapes in backslash notation in the string 284ab5a295bSJuli Mallett.Ar argument . 2853cf53e85SJilles TjoelkerThe permitted escape sequences are slightly different in that 2863cf53e85SJilles Tjoelkeroctal escapes are 2873cf53e85SJilles Tjoelker.Cm \e0 Ns Ar num 2883cf53e85SJilles Tjoelkerinstead of 2892bf7d924SJilles Tjoelker.Cm \e Ns Ar num 2902bf7d924SJilles Tjoelkerand that an additional escape sequence 2912bf7d924SJilles Tjoelker.Cm \ec 2922bf7d924SJilles Tjoelkerstops further output from this 2932bf7d924SJilles Tjoelker.Nm 2942bf7d924SJilles Tjoelkerinvocation. 295b0620803SPedro F. Giffuni.It Cm n$ 296b0620803SPedro F. GiffuniAllows reordering of the output according to 297b0620803SPedro F. Giffuni.Ar argument . 2989b50d902SRodney W. Grimes.It Cm \&% 2999b50d902SRodney W. GrimesPrint a `%'; no argument is used. 3009b50d902SRodney W. Grimes.El 3019b50d902SRodney W. Grimes.Pp 302dc7d8c99SAndrey A. ChernovThe decimal point 303429d919cSRuslan Ermilovcharacter is defined in the program's locale (category 304429d919cSRuslan Ermilov.Dv LC_NUMERIC ) . 305dc7d8c99SAndrey A. Chernov.Pp 3069b50d902SRodney W. GrimesIn no case does a non-existent or small field width cause truncation of 3079b50d902SRodney W. Grimesa field; padding takes place only if the specified field width exceeds 3089b50d902SRodney W. Grimesthe actual width. 3099897c45fSJilles Tjoelker.Pp 3109897c45fSJilles TjoelkerSome shells may provide a builtin 3119897c45fSJilles Tjoelker.Nm 3129897c45fSJilles Tjoelkercommand which is similar or identical to this utility. 3139897c45fSJilles TjoelkerConsult the 3149897c45fSJilles Tjoelker.Xr builtin 1 3159897c45fSJilles Tjoelkermanual page. 316a866e170SRuslan Ermilov.Sh EXIT STATUS 317c24ca63dSDima Dorfman.Ex -std 318*5dbd4b8eSFernando Apesteguía.Sh EXAMPLES 319*5dbd4b8eSFernando ApesteguíaPrint the string 320*5dbd4b8eSFernando Apesteguía.Qq hello : 321*5dbd4b8eSFernando Apesteguía.Bd -literal -offset indent 322*5dbd4b8eSFernando Apesteguía$ printf "%s\en" hello 323*5dbd4b8eSFernando Apesteguíahello 324*5dbd4b8eSFernando Apesteguía.Ed 325*5dbd4b8eSFernando Apesteguía.Pp 326*5dbd4b8eSFernando ApesteguíaSame as above, but notice that the format string is not quoted and hence we 327*5dbd4b8eSFernando Apesteguíado not get the expected behavior: 328*5dbd4b8eSFernando Apesteguía.Bd -literal -offset indent 329*5dbd4b8eSFernando Apesteguía$ printf %s\en hello 330*5dbd4b8eSFernando Apesteguíahellon$ 331*5dbd4b8eSFernando Apesteguía.Ed 332*5dbd4b8eSFernando Apesteguía.Pp 333*5dbd4b8eSFernando ApesteguíaPrint arguments forcing sign only for the first argument: 334*5dbd4b8eSFernando Apesteguía.Bd -literal -offset indent 335*5dbd4b8eSFernando Apesteguía$ printf "%+d\en%d\en%d\en" 1 -2 13 336*5dbd4b8eSFernando Apesteguía+1 337*5dbd4b8eSFernando Apesteguía-2 338*5dbd4b8eSFernando Apesteguía13 339*5dbd4b8eSFernando Apesteguía.Ed 340*5dbd4b8eSFernando Apesteguía.Pp 341*5dbd4b8eSFernando ApesteguíaSame as above, but the single format string will be applied to the three 342*5dbd4b8eSFernando Apesteguíaarguments: 343*5dbd4b8eSFernando Apesteguía.Bd -literal -offset indent 344*5dbd4b8eSFernando Apesteguía$ printf "%+d\en" 1 -2 13 345*5dbd4b8eSFernando Apesteguía+1 346*5dbd4b8eSFernando Apesteguía-2 347*5dbd4b8eSFernando Apesteguía+13 348*5dbd4b8eSFernando Apesteguía.Ed 349*5dbd4b8eSFernando Apesteguía.Pp 350*5dbd4b8eSFernando ApesteguíaPrint number using only two digits after the decimal point: 351*5dbd4b8eSFernando Apesteguía.Bd -literal -offset indent 352*5dbd4b8eSFernando Apesteguía$ printf "%.2f\en" 31.7456 353*5dbd4b8eSFernando Apesteguía31.75 354*5dbd4b8eSFernando Apesteguía.Ed 355ab5a295bSJuli Mallett.Sh COMPATIBILITY 356ab5a295bSJuli MallettThe traditional 357ab5a295bSJuli Mallett.Bx 358ab5a295bSJuli Mallettbehavior of converting arguments of numeric formats not beginning 359*5dbd4b8eSFernando Apesteguíawith a digit to the ASCII 360806968d6SGiorgos Keramidascode of the first character is not supported. 3619b50d902SRodney W. Grimes.Sh SEE ALSO 3629897c45fSJilles Tjoelker.Xr builtin 1 , 363ab5a295bSJuli Mallett.Xr echo 1 , 3649897c45fSJilles Tjoelker.Xr sh 1 , 3655521ff5aSRuslan Ermilov.Xr printf 3 366ab5a295bSJuli Mallett.Sh STANDARDS 367ab5a295bSJuli MallettThe 368ab5a295bSJuli Mallett.Nm 369ab5a295bSJuli Mallettcommand is expected to be compatible with the 370ab5a295bSJuli Mallett.St -p1003.2 371ab5a295bSJuli Mallettspecification. 3729b50d902SRodney W. Grimes.Sh HISTORY 3739b50d902SRodney W. GrimesThe 37469d85135SPhilippe Charnier.Nm 3759b50d902SRodney W. Grimescommand appeared in 3769b50d902SRodney W. Grimes.Bx 4.3 Reno . 3779b50d902SRodney W. GrimesIt is modeled 3789b50d902SRodney W. Grimesafter the standard library function, 3799b50d902SRodney W. Grimes.Xr printf 3 . 3801792d820SJilles Tjoelker.Sh CAVEATS 381*5dbd4b8eSFernando ApesteguíaANSI hexadecimal character constants were deliberately not provided. 3821792d820SJilles Tjoelker.Pp 3831792d820SJilles TjoelkerTrying to print a dash ("-") as the first character causes 3841792d820SJilles Tjoelker.Nm 3851792d820SJilles Tjoelkerto interpret the dash as a program argument. 3861792d820SJilles Tjoelker.Nm -- 3871792d820SJilles Tjoelkermust be used before 3881792d820SJilles Tjoelker.Ar format . 38927a43b2eSJilles Tjoelker.Pp 39027a43b2eSJilles TjoelkerIf the locale contains multibyte characters 39127a43b2eSJilles Tjoelker(such as UTF-8), 39227a43b2eSJilles Tjoelkerthe 39327a43b2eSJilles Tjoelker.Cm c 39427a43b2eSJilles Tjoelkerformat and 39527a43b2eSJilles Tjoelker.Cm b 39627a43b2eSJilles Tjoelkerand 39727a43b2eSJilles Tjoelker.Cm s 39827a43b2eSJilles Tjoelkerformats with a precision 39927a43b2eSJilles Tjoelkermay not operate as expected. 4009b50d902SRodney W. Grimes.Sh BUGS 401*5dbd4b8eSFernando ApesteguíaSince the floating point numbers are translated from ASCII 402*5dbd4b8eSFernando Apesteguíato floating-point and then back again, floating-point precision may be lost. 403fd757c50SDavid Schultz(By default, the number is translated to an IEEE-754 double-precision 404fd757c50SDavid Schultzvalue before being printed. 405fd757c50SDavid SchultzThe 406fd757c50SDavid Schultz.Cm L 407fd757c50SDavid Schultzmodifier may produce additional precision, depending on the hardware platform.) 4089b50d902SRodney W. Grimes.Pp 4096a3e8b0aSRuslan ErmilovThe escape sequence \e000 is the string terminator. 410e897c4d6SStefan FarfelederWhen present in the argument for the 411e897c4d6SStefan Farfeleder.Cm b 412e897c4d6SStefan Farfelederformat, the argument will be truncated at the \e000 character. 4134f45d811STim J. Robbins.Pp 4144f45d811STim J. RobbinsMultibyte characters are not recognized in format strings (this is only 4154f45d811STim J. Robbinsa problem if 4162e94ae7eSTim J. Robbins.Ql % 4172e94ae7eSTim J. Robbinscan appear inside a multibyte character). 418