You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
543 lines
38 KiB
HTML
543 lines
38 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en" class="sidebar-visible no-js light">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>printf - uutils Documentation</title>
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
<style>
|
|
dd {
|
|
margin-bottom: 1em;
|
|
}
|
|
main {
|
|
position: relative;
|
|
}
|
|
.additional {
|
|
position: absolute;
|
|
top: 0.5em;
|
|
right: 0;
|
|
display: flex;
|
|
gap: 5px;
|
|
align-items: center;
|
|
font-size: 1.3em;
|
|
}
|
|
.platforms {
|
|
font-size: 2rem;
|
|
}
|
|
dd > p {
|
|
margin-top: 0.2em;
|
|
}
|
|
</style>
|
|
|
|
<meta name="description" content="">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff" />
|
|
|
|
<link rel="icon" href="../favicon.svg">
|
|
<link rel="stylesheet" href="../css/variables.css">
|
|
<link rel="stylesheet" href="../css/general.css">
|
|
<link rel="stylesheet" href="../css/chrome.css">
|
|
<link rel="stylesheet" href="../css/print.css" media="print">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
|
|
<link rel="stylesheet" href="../fonts/fonts.css">
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" href="../highlight.css">
|
|
<link rel="stylesheet" href="../tomorrow-night.css">
|
|
<link rel="stylesheet" href="../ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
|
|
</head>
|
|
<body>
|
|
<div id="body-container">
|
|
<!-- Provide site root to javascript -->
|
|
<script>
|
|
var path_to_root = "../";
|
|
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
|
|
</script>
|
|
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|
<script>
|
|
try {
|
|
var theme = localStorage.getItem('mdbook-theme');
|
|
var sidebar = localStorage.getItem('mdbook-sidebar');
|
|
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|
}
|
|
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
}
|
|
} catch (e) { }
|
|
</script>
|
|
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|
<script>
|
|
var theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
var html = document.querySelector('html');
|
|
html.classList.remove('no-js')
|
|
html.classList.remove('light')
|
|
html.classList.add(theme);
|
|
html.classList.add('js');
|
|
</script>
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
var html = document.querySelector('html');
|
|
var sidebar = null;
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
}
|
|
html.classList.remove('sidebar-visible');
|
|
html.classList.add("sidebar-" + sidebar);
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<div class="sidebar-scrollbox">
|
|
<ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html">Introduction</a></li><li class="chapter-item expanded "><a href="../installation.html"><strong aria-hidden="true">1.</strong> Installation</a></li><li class="chapter-item expanded "><a href="../build.html"><strong aria-hidden="true">2.</strong> Build from source</a></li><li class="chapter-item expanded "><a href="../contributing.html"><strong aria-hidden="true">3.</strong> Contributing</a></li><li class="chapter-item expanded "><a href="../test_coverage.html"><strong aria-hidden="true">4.</strong> GNU test coverage</a></li><li class="chapter-item expanded "><a href="../extensions.html"><strong aria-hidden="true">5.</strong> Extensions</a></li><li class="chapter-item expanded affix "><li class="part-title">Reference</li><li class="chapter-item expanded "><a href="../multicall.html"><strong aria-hidden="true">6.</strong> Multi-call binary</a></li><li class="chapter-item expanded "><a href="../utils/arch.html"><strong aria-hidden="true">7.</strong> arch</a></li><li class="chapter-item expanded "><a href="../utils/b2sum.html"><strong aria-hidden="true">8.</strong> b2sum</a></li><li class="chapter-item expanded "><a href="../utils/b3sum.html"><strong aria-hidden="true">9.</strong> b3sum</a></li><li class="chapter-item expanded "><a href="../utils/base32.html"><strong aria-hidden="true">10.</strong> base32</a></li><li class="chapter-item expanded "><a href="../utils/base64.html"><strong aria-hidden="true">11.</strong> base64</a></li><li class="chapter-item expanded "><a href="../utils/basename.html"><strong aria-hidden="true">12.</strong> basename</a></li><li class="chapter-item expanded "><a href="../utils/basenc.html"><strong aria-hidden="true">13.</strong> basenc</a></li><li class="chapter-item expanded "><a href="../utils/cat.html"><strong aria-hidden="true">14.</strong> cat</a></li><li class="chapter-item expanded "><a href="../utils/chcon.html"><strong aria-hidden="true">15.</strong> chcon</a></li><li class="chapter-item expanded "><a href="../utils/chgrp.html"><strong aria-hidden="true">16.</strong> chgrp</a></li><li class="chapter-item expanded "><a href="../utils/chmod.html"><strong aria-hidden="true">17.</strong> chmod</a></li><li class="chapter-item expanded "><a href="../utils/chown.html"><strong aria-hidden="true">18.</strong> chown</a></li><li class="chapter-item expanded "><a href="../utils/chroot.html"><strong aria-hidden="true">19.</strong> chroot</a></li><li class="chapter-item expanded "><a href="../utils/cksum.html"><strong aria-hidden="true">20.</strong> cksum</a></li><li class="chapter-item expanded "><a href="../utils/comm.html"><strong aria-hidden="true">21.</strong> comm</a></li><li class="chapter-item expanded "><a href="../utils/cp.html"><strong aria-hidden="true">22.</strong> cp</a></li><li class="chapter-item expanded "><a href="../utils/csplit.html"><strong aria-hidden="true">23.</strong> csplit</a></li><li class="chapter-item expanded "><a href="../utils/cut.html"><strong aria-hidden="true">24.</strong> cut</a></li><li class="chapter-item expanded "><a href="../utils/date.html"><strong aria-hidden="true">25.</strong> date</a></li><li class="chapter-item expanded "><a href="../utils/dd.html"><strong aria-hidden="true">26.</strong> dd</a></li><li class="chapter-item expanded "><a href="../utils/df.html"><strong aria-hidden="true">27.</strong> df</a></li><li class="chapter-item expanded "><a href="../utils/dir.html"><strong aria-hidden="true">28.</strong> dir</a></li><li class="chapter-item expanded "><a href="../utils/dircolors.html"><strong aria-hidden="true">29.</strong> dircolors</a></li><li class="chapter-item expanded "><a href="../utils/dirname.html"><strong aria-hidden="true">30.</strong> dirname</a></li><li class="chapter-item expanded "><a href="../utils/du.html"><strong aria-hidden="true">31.</strong> du</a></li><li class="chapter-item expanded "><a href="../utils/echo.html"><strong aria-hidden="true">32.</strong> echo</a></li><li class="chapter-item expanded "><a href="../utils/env.html"><strong aria-hidden="true">33.</strong> env</a></li><li class="chapter-item expanded "><a href="../utils/expand.html"><strong aria-hidden="true">34.</strong> expand</a></li><li class="chapter-item expanded "><a href="../utils/expr.html"><strong aria-hidden="true">35.</strong> expr</a></li><li class="chapter-item expanded "><a href="../utils/factor.html"><strong aria-hidden="true">36.</strong> factor</a></li><li class="chapter-item expanded "><a href="../utils/false.html"><strong aria-hidden="true">37.</strong> false</a></li><li class="chapter-item expanded "><a href="../utils/fmt.html"><strong aria-hidden="true">38.</strong> fmt</a></li><li class="chapter-item expanded "><a href="../utils/fold.html"><strong aria-hidden="true">39.</strong> fold</a></li><li class="chapter-item expanded "><a href="../utils/groups.html"><strong aria-hidden="true">40.</strong> groups</a></li><li class="chapter-item expanded "><a href="../utils/hashsum.html"><strong aria-hidden="true">41.</strong> hashsum</a></li><li class="chapter-item expanded "><a href="../utils/head.html"><strong aria-hidden="true">42.</strong> head</a></li><li class="chapter-item expanded "><a href="../utils/hostid.html"><strong aria-hidden="true">43.</strong> hostid</a></li><li class="chapter-item expanded "><a href="../utils/hostname.html"><strong aria-hidden="true">44.</strong> hostname</a></li><li class="chapter-item expanded "><a href="../utils/id.html"><strong aria-hidden="true">45.</strong> id</a></li><li class="chapter-item expanded "><a href="../utils/install.html"><strong aria-hidden="true">46.</strong> install</a></li><li class="chapter-item expanded "><a href="../utils/join.html"><strong aria-hidden="true">47.</strong> join</a></li><li class="chapter-item expanded "><a href="../utils/kill.html"><strong aria-hidden="true">48.</strong> kill</a></li><li class="chapter-item expanded "><a href="../utils/link.html"><strong aria-hidden="true">49.</strong> link</a></li><li class="chapter-item expanded "><a href="../utils/ln.html"><strong aria-hidden="true">50.</strong> ln</a></li><li class="chapter-item expanded "><a href="../utils/logname.html"><strong aria-hidden="true">51.</strong> logname</a></li><li class="chapter-item expanded "><a href="../utils/ls.html"><strong aria-hidden="true">52.</strong> ls</a></li><li class="chapter-item expanded "><a href="../utils/md5sum.html"><strong aria-hidden="true">53.</strong> md5sum</a></li><li class="chapter-item expanded "><a href="../utils/mkdir.html"><strong aria-hidden="true">54.</strong> mkdir</a></li><li class="chapter-item expanded "><a href="../utils/mkfifo.html"><strong aria-hidden="true">55.</strong> mkfifo</a></li><li class="chapter-item expanded "><a href="../utils/mknod.html"><strong aria-hidden="true">56.</strong> mknod</a></li><li class="chapter-item expanded "><a href="../utils/mktemp.html"><strong aria-hidden="true">57.</strong> mktemp</a></li><li class="chapter-item expanded "><a href="../utils/more.html"><strong aria-hidden="true">58.</strong> more</a></li><li class="chapter-item expanded "><a href="../utils/mv.html"><strong aria-hidden="true">59.</strong> mv</a></li><li class="chapter-item expanded "><a href="../utils/nice.html"><strong aria-hidden="true">60.</strong> nice</a></li><li class="chapter-item expanded "><a href="../utils/nl.html"><strong aria-hidden="true">61.</strong> nl</a></li><li class="chapter-item expanded "><a href="../utils/nohup.html"><strong aria-hidden="true">62.</strong> nohup</a></li><li class="chapter-item expanded "><a href="../utils/nproc.html"><strong aria-hidden="true">63.</strong> nproc</a></li><li class="chapter-item expanded "><a href="../utils/numfmt.html"><strong aria-hidden="true">64.</strong> numfmt</a></li><li class="chapter-item expanded "><a href="../utils/od.html"><strong aria-hidden="true">65.</strong> od</a></li><li class="chapter-item expanded "><a href="../utils/paste.html"><strong aria-hidden="true">66.</strong> paste</a></li><li class="chapter-item expanded "><a href="../utils/pathchk.html"><strong aria-hidden="true">67.</strong> pathchk</a></li><li class="chapter-item expanded "><a href="../utils/pinky.html"><strong aria-hidden="true">68.</strong> pinky</a></li><li class="chapter-item expanded "><a href="../utils/pr.html"><strong aria-hidden="true">69.</strong> pr</a></li><li class="chapter-item expanded "><a href="../utils/printenv.html"><strong aria-hidden="true">70.</strong> printenv</a></li><li class="chapter-item expanded "><a href="../utils/printf.html" class="active"><strong aria-hidden="true">71.</strong> printf</a></li><li class="chapter-item expanded "><a href="../utils/ptx.html"><strong aria-hidden="true">72.</strong> ptx</a></li><li class="chapter-item expanded "><a href="../utils/pwd.html"><strong aria-hidden="true">73.</strong> pwd</a></li><li class="chapter-item expanded "><a href="../utils/readlink.html"><strong aria-hidden="true">74.</strong> readlink</a></li><li class="chapter-item expanded "><a href="../utils/realpath.html"><strong aria-hidden="true">75.</strong> realpath</a></li><li class="chapter-item expanded "><a href="../utils/relpath.html"><strong aria-hidden="true">76.</strong> relpath</a></li><li class="chapter-item expanded "><a href="../utils/rm.html"><strong aria-hidden="true">77.</strong> rm</a></li><li class="chapter-item expanded "><a href="../utils/rmdir.html"><strong aria-hidden="true">78.</strong> rmdir</a></li><li class="chapter-item expanded "><a href="../utils/runcon.html"><strong aria-hidden="true">79.</strong> runcon</a></li><li class="chapter-item expanded "><a href="../utils/seq.html"><strong aria-hidden="true">80.</strong> seq</a></li><li class="chapter-item expanded "><a href="../utils/sha1sum.html"><strong aria-hidden="true">81.</strong> sha1sum</a></li><li class="chapter-item expanded "><a href="../utils/sha224sum.html"><strong aria-hidden="true">82.</strong> sha224sum</a></li><li class="chapter-item expanded "><a href="../utils/sha256sum.html"><strong aria-hidden="true">83.</strong> sha256sum</a></li><li class="chapter-item expanded "><a href="../utils/sha3-224sum.html"><strong aria-hidden="true">84.</strong> sha3-224sum</a></li><li class="chapter-item expanded "><a href="../utils/sha3-256sum.html"><strong aria-hidden="true">85.</strong> sha3-256sum</a></li><li class="chapter-item expanded "><a href="../utils/sha3-384sum.html"><strong aria-hidden="true">86.</strong> sha3-384sum</a></li><li class="chapter-item expanded "><a href="../utils/sha3-512sum.html"><strong aria-hidden="true">87.</strong> sha3-512sum</a></li><li class="chapter-item expanded "><a href="../utils/sha384sum.html"><strong aria-hidden="true">88.</strong> sha384sum</a></li><li class="chapter-item expanded "><a href="../utils/sha3sum.html"><strong aria-hidden="true">89.</strong> sha3sum</a></li><li class="chapter-item expanded "><a href="../utils/sha512sum.html"><strong aria-hidden="true">90.</strong> sha512sum</a></li><li class="chapter-item expanded "><a href="../utils/shake128sum.html"><strong aria-hidden="true">91.</strong> shake128sum</a></li><li class="chapter-item expanded "><a href="../utils/shake256sum.html"><strong aria-hidden="true">92.</strong> shake256sum</a></li><li class="chapter-item expanded "><a href="../utils/shred.html"><strong aria-hidden="true">93.</strong> shred</a></li><li class="chapter-item expanded "><a href="../utils/shuf.html"><strong aria-hidden="true">94.</strong> shuf</a></li><li class="chapter-item expanded "><a href="../utils/sleep.html"><strong aria-hidden="true">95.</strong> sleep</a></li><li class="chapter-item expanded "><a href="../utils/sort.html"><strong aria-hidden="true">96.</strong> sort</a></li><li class="chapter-item expanded "><a href="../utils/split.html"><strong aria-hidden="true">97.</strong> split</a></li><li class="chapter-item expanded "><a href="../utils/stat.html"><strong aria-hidden="true">98.</strong> stat</a></li><li class="chapter-item expanded "><a href="../utils/stdbuf.html"><strong aria-hidden="true">99.</strong> stdbuf</a></li><li class="chapter-item expanded "><a href="../utils/stty.html"><strong aria-hidden="true">100.</strong> stty</a></li><li class="chapter-item expanded "><a href="../utils/sum.html"><strong aria-hidden="true">101.</strong> sum</a></li><li class="chapter-item expanded "><a href="../utils/sync.html"><strong aria-hidden="true">102.</strong> sync</a></li><li class="chapter-item expanded "><a href="../utils/tac.html"><strong aria-hidden="true">103.</strong> tac</a></li><li class="chapter-item expanded "><a href="../utils/tail.html"><strong aria-hidden="true">104.</strong> tail</a></li><li class="chapter-item expanded "><a href="../utils/tee.html"><strong aria-hidden="true">105.</strong> tee</a></li><li class="chapter-item expanded "><a href="../utils/test.html"><strong aria-hidden="true">106.</strong> test</a></li><li class="chapter-item expanded "><a href="../utils/timeout.html"><strong aria-hidden="true">107.</strong> timeout</a></li><li class="chapter-item expanded "><a href="../utils/touch.html"><strong aria-hidden="true">108.</strong> touch</a></li><li class="chapter-item expanded "><a href="../utils/tr.html"><strong aria-hidden="true">109.</strong> tr</a></li><li class="chapter-item expanded "><a href="../utils/true.html"><strong aria-hidden="true">110.</strong> true</a></li><li class="chapter-item expanded "><a href="../utils/truncate.html"><strong aria-hidden="true">111.</strong> truncate</a></li><li class="chapter-item expanded "><a href="../utils/tsort.html"><strong aria-hidden="true">112.</strong> tsort</a></li><li class="chapter-item expanded "><a href="../utils/tty.html"><strong aria-hidden="true">113.</strong> tty</a></li><li class="chapter-item expanded "><a href="../utils/uname.html"><strong aria-hidden="true">114.</strong> uname</a></li><li class="chapter-item expanded "><a href="../utils/unexpand.html"><strong aria-hidden="true">115.</strong> unexpand</a></li><li class="chapter-item expanded "><a href="../utils/uniq.html"><strong aria-hidden="true">116.</strong> uniq</a></li><li class="chapter-item expanded "><a href="../utils/unlink.html"><strong aria-hidden="true">117.</strong> unlink</a></li><li class="chapter-item expanded "><a href="../utils/uptime.html"><strong aria-hidden="true">118.</strong> uptime</a></li><li class="chapter-item expanded "><a href="../utils/users.html"><strong aria-hidden="true">119.</strong> users</a></li><li class="chapter-item expanded "><a href="../utils/vdir.html"><strong aria-hidden="true">120.</strong> vdir</a></li><li class="chapter-item expanded "><a href="../utils/wc.html"><strong aria-hidden="true">121.</strong> wc</a></li><li class="chapter-item expanded "><a href="../utils/who.html"><strong aria-hidden="true">122.</strong> who</a></li><li class="chapter-item expanded "><a href="../utils/whoami.html"><strong aria-hidden="true">123.</strong> whoami</a></li><li class="chapter-item expanded "><a href="../utils/yes.html"><strong aria-hidden="true">124.</strong> yes</a></li></ol>
|
|
</div>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
|
|
</nav>
|
|
|
|
<!-- Track and set sidebar scroll position -->
|
|
<script>
|
|
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
|
|
sidebarScrollbox.addEventListener('click', function(e) {
|
|
if (e.target.tagName === 'A') {
|
|
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
|
|
}
|
|
}, { passive: true });
|
|
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
|
|
sessionStorage.removeItem('sidebar-scroll');
|
|
if (sidebarScrollTop) {
|
|
// preserve sidebar scroll position when navigating via links within sidebar
|
|
sidebarScrollbox.scrollTop = sidebarScrollTop;
|
|
} else {
|
|
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
|
|
var activeSection = document.querySelector('#sidebar .active');
|
|
if (activeSection) {
|
|
activeSection.scrollIntoView({ block: 'center' });
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</button>
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|
</ul>
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<h1 class="menu-title">uutils Documentation</h1>
|
|
|
|
<div class="right-buttons">
|
|
<a href="../print.html" title="Print this book" aria-label="Print this book">
|
|
<i id="print-button" class="fa fa-print"></i>
|
|
</a>
|
|
<a href="https://github.com/rust-lang/cargo/tree/master/src/doc/src" title="Git repository" aria-label="Git repository">
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<h1 id="printf"><a class="header" href="#printf">printf</a></h1>
|
|
<div class="additional">
|
|
<div class="platforms">
|
|
<i class="fa fa-brands fa-linux"></i>
|
|
<i class="fa fa-brands fa-apple"></i>
|
|
<i class="fa fa-brands fa-windows"></i>
|
|
</div>
|
|
<div class="version">v0.0.19
|
|
</div>
|
|
</div>
|
|
<pre><code>printf FORMATSTRING [ARGUMENT]...
|
|
</code></pre>
|
|
<p>Print output based off of the format string and proceeding arguments.</p>
|
|
<h2 id="options"><a class="header" href="#options">Options</a></h2>
|
|
<dl><dt><code>--help</code></dt>
|
|
<dd>
|
|
<p>Print help information</p>
|
|
</dd>
|
|
<dt><code>--version</code></dt>
|
|
<dd>
|
|
<p>Print version information</p>
|
|
</dd>
|
|
<dt></dt>
|
|
<dd>
|
|
</dd>
|
|
<dt></dt>
|
|
<dd>
|
|
</dd>
|
|
</dl>
|
|
<p>basic anonymous string templating:</p>
|
|
<p>prints format string at least once, repeating as long as there are remaining arguments
|
|
output prints escaped literals in the format string as character literals
|
|
output replaces anonymous fields with the next unused argument, formatted according to the field.</p>
|
|
<p>Prints the <code>,</code> replacing escaped character sequences with character literals
|
|
and substitution field sequences with passed arguments</p>
|
|
<p>literally, with the exception of the below
|
|
escaped character sequences, and the substitution sequences described further down.</p>
|
|
<h3 id="escape-sequences"><a class="header" href="#escape-sequences">ESCAPE SEQUENCES</a></h3>
|
|
<p>The following escape sequences, organized here in alphabetical order,
|
|
will print the corresponding character literal:</p>
|
|
<ul>
|
|
<li>
|
|
<p><code>\"</code> double quote</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\\\</code> backslash</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\a</code> alert (BEL)</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\b</code> backspace</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\c</code> End-of-Input</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\e</code> escape</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\f</code> form feed</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\n</code> new line</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\r</code> carriage return</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\t</code> horizontal tab</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\v</code> vertical tab</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\NNN</code> byte with value expressed in octal value NNN (1 to 3 digits)
|
|
values greater than 256 will be treated</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\xHH</code> byte with value expressed in hexadecimal value NN (1 to 2 digits)</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\uHHHH</code> Unicode (IEC 10646) character with value expressed in hexadecimal value HHHH (4 digits)</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\\uHHHH</code> Unicode character with value expressed in hexadecimal value HHHH (8 digits)</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%%</code> a single %</p>
|
|
</li>
|
|
</ul>
|
|
<h3 id="substitutions"><a class="header" href="#substitutions">SUBSTITUTIONS</a></h3>
|
|
<h4 id="substitution-quick-reference"><a class="header" href="#substitution-quick-reference">SUBSTITUTION QUICK REFERENCE</a></h4>
|
|
<p>Fields</p>
|
|
<ul>
|
|
<li>
|
|
<p><code>%s</code>: string</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%b</code>: string parsed for literals second parameter is max length</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%c</code>: char no second parameter</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%i</code> or <code>%d</code>: 64-bit integer</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%u</code>: 64 bit unsigned integer</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%x</code> or <code>%X</code>: 64-bit unsigned integer as hex</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%o</code>: 64-bit unsigned integer as octal
|
|
second parameter is min-width, integer
|
|
output below that width is padded with leading zeroes</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%f</code> or <code>%F</code>: decimal floating point value</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%e</code> or <code>%E</code>: scientific notation floating point value</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%g</code> or <code>%G</code>: shorter of specially interpreted decimal or SciNote floating point value.
|
|
second parameter is
|
|
<code>-max</code> places after decimal point for floating point output
|
|
<code>-max</code> number of significant digits for scientific notation output</p>
|
|
</li>
|
|
</ul>
|
|
<p>parameterizing fields</p>
|
|
<p>examples:</p>
|
|
<pre><code>printf '%4.3i' 7
|
|
</code></pre>
|
|
<p>It has a first parameter of 4 and a second parameter of 3 and will result in ' 007'</p>
|
|
<pre><code>printf '%.1s' abcde
|
|
</code></pre>
|
|
<p>It has no first parameter and a second parameter of 1 and will result in 'a'</p>
|
|
<pre><code>printf '%4c' q
|
|
</code></pre>
|
|
<p>It has a first parameter of 4 and no second parameter and will result in ' q'</p>
|
|
<p>The first parameter of a field is the minimum width to pad the output to
|
|
if the output is less than this absolute value of this width,
|
|
it will be padded with leading spaces, or, if the argument is negative,
|
|
with trailing spaces. the default is zero.</p>
|
|
<p>The second parameter of a field is particular to the output field type.
|
|
defaults can be found in the full substitution help below</p>
|
|
<p>special prefixes to numeric arguments</p>
|
|
<ul>
|
|
<li><code>0</code>: (e.g. 010) interpret argument as octal (integer output fields only)</li>
|
|
<li><code>0x</code>: (e.g. 0xABC) interpret argument as hex (numeric output fields only)</li>
|
|
<li><code>\'</code>: (e.g. 'a) interpret argument as a character constant</li>
|
|
</ul>
|
|
<h4 id="how-to-use-substitutions"><a class="header" href="#how-to-use-substitutions">HOW TO USE SUBSTITUTIONS</a></h4>
|
|
<p>Substitutions are used to pass additional argument(s) into the FORMAT string, to be formatted a
|
|
particular way. E.g.</p>
|
|
<pre><code>printf 'the letter %X comes before the letter %X' 10 11
|
|
</code></pre>
|
|
<p>will print</p>
|
|
<pre><code>the letter A comes before the letter B
|
|
</code></pre>
|
|
<p>because the substitution field <code>%X</code> means
|
|
'take an integer argument and write it as a hexadecimal number'</p>
|
|
<p>Passing more arguments than are in the format string will cause the format string to be
|
|
repeated for the remaining substitutions</p>
|
|
<pre><code>printf 'it is %i F in %s \n' 22 Portland 25 Boston 27 New York
|
|
</code></pre>
|
|
<p>will print</p>
|
|
<pre><code>it is 22 F in Portland
|
|
it is 25 F in Boston
|
|
it is 27 F in Boston
|
|
</code></pre>
|
|
<p>If a format string is printed but there are less arguments remaining
|
|
than there are substitution fields, substitution fields without
|
|
an argument will default to empty strings, or for numeric fields
|
|
the value 0</p>
|
|
<h4 id="available-substitutions"><a class="header" href="#available-substitutions">AVAILABLE SUBSTITUTIONS</a></h4>
|
|
<p>This program, like GNU coreutils printf,
|
|
interprets a modified subset of the POSIX C printf spec,
|
|
a quick reference to substitutions is below.</p>
|
|
<h4 id="string-substitutions"><a class="header" href="#string-substitutions">STRING SUBSTITUTIONS</a></h4>
|
|
<p>All string fields have a 'max width' parameter
|
|
<code>%.3s</code> means 'print no more than three characters of the original input'</p>
|
|
<ul>
|
|
<li>
|
|
<p><code>%s</code>: string</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%b</code>: escaped string - the string will be checked for any escaped literals from
|
|
the escaped literal list above, and translate them to literal characters.
|
|
e.g. <code>\\n</code> will be transformed into a newline character.
|
|
One special rule about <code>%b</code> mode is that octal literals are interpreted differently
|
|
In arguments passed by <code>%b</code>, pass octal-interpreted literals must be in the form of <code>\\0NNN</code>
|
|
instead of <code>\\NNN</code>. (Although, for legacy reasons, octal literals in the form of <code>\\NNN</code> will
|
|
still be interpreted and not throw a warning, you will have problems if you use this for a
|
|
literal whose code begins with zero, as it will be viewed as in <code>\\0NNN</code> form.)</p>
|
|
</li>
|
|
</ul>
|
|
<h4 id="char-substitutions"><a class="header" href="#char-substitutions">CHAR SUBSTITUTIONS</a></h4>
|
|
<p>The character field does not have a secondary parameter.</p>
|
|
<ul>
|
|
<li><code>%c</code>: a single character</li>
|
|
</ul>
|
|
<h4 id="integer-substitutions"><a class="header" href="#integer-substitutions">INTEGER SUBSTITUTIONS</a></h4>
|
|
<p>All integer fields have a 'pad with zero' parameter
|
|
<code>%.4i</code> means an integer which if it is less than 4 digits in length,
|
|
is padded with leading zeros until it is 4 digits in length.</p>
|
|
<ul>
|
|
<li>
|
|
<p><code>%d</code> or <code>%i</code>: 64-bit integer</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%u</code>: 64-bit unsigned integer</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%x</code> or <code>%X</code>: 64-bit unsigned integer printed in Hexadecimal (base 16)
|
|
<code>%X</code> instead of <code>%x</code> means to use uppercase letters for 'a' through 'f'</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%o</code>: 64-bit unsigned integer printed in octal (base 8)</p>
|
|
</li>
|
|
</ul>
|
|
<h4 id="floating-point-substitutions"><a class="header" href="#floating-point-substitutions">FLOATING POINT SUBSTITUTIONS</a></h4>
|
|
<p>All floating point fields have a 'max decimal places / max significant digits' parameter
|
|
<code>%.10f</code> means a decimal floating point with 7 decimal places past 0
|
|
<code>%.10e</code> means a scientific notation number with 10 significant digits
|
|
<code>%.10g</code> means the same behavior for decimal and Sci. Note, respectively, and provides the shortest
|
|
of each's output.</p>
|
|
<p>Like with GNU coreutils, the value after the decimal point is these outputs is parsed as a
|
|
double first before being rendered to text. For both implementations do not expect meaningful
|
|
precision past the 18th decimal place. When using a number of decimal places that is 18 or
|
|
higher, you can expect variation in output between GNU coreutils printf and this printf at the
|
|
18th decimal place of +/- 1</p>
|
|
<ul>
|
|
<li>
|
|
<p><code>%f</code>: floating point value presented in decimal, truncated and displayed to 6 decimal places by
|
|
default. There is not past-double behavior parity with Coreutils printf, values are not
|
|
estimated or adjusted beyond input values.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%e</code> or <code>%E</code>: floating point value presented in scientific notation
|
|
7 significant digits by default
|
|
<code>%E</code> means use to use uppercase E for the mantissa.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>%g</code> or <code>%G</code>: floating point value presented in the shortest of decimal and scientific notation
|
|
behaves differently from <code>%f</code> and <code>%E</code>, please see posix printf spec for full details,
|
|
some examples of different behavior:
|
|
Sci Note has 6 significant digits by default
|
|
Trailing zeroes are removed
|
|
Instead of being truncated, digit after last is rounded</p>
|
|
</li>
|
|
</ul>
|
|
<p>Like other behavior in this utility, the design choices of floating point
|
|
behavior in this utility is selected to reproduce in exact
|
|
the behavior of GNU coreutils' printf from an inputs and outputs standpoint.</p>
|
|
<h3 id="using-parameters"><a class="header" href="#using-parameters">USING PARAMETERS</a></h3>
|
|
<p>Most substitution fields can be parameterized using up to 2 numbers that can
|
|
be passed to the field, between the % sign and the field letter.</p>
|
|
<p>The 1st parameter always indicates the minimum width of output, it is useful for creating
|
|
columnar output. Any output that would be less than this minimum width is padded with
|
|
leading spaces
|
|
The 2nd parameter is proceeded by a dot.
|
|
You do not have to use parameters</p>
|
|
<h3 id="special-forms-of-input"><a class="header" href="#special-forms-of-input">SPECIAL FORMS OF INPUT</a></h3>
|
|
<p>For numeric input, the following additional forms of input are accepted besides decimal:</p>
|
|
<p>Octal (only with integer): if the argument begins with a 0 the proceeding characters
|
|
will be interpreted as octal (base 8) for integer fields</p>
|
|
<p>Hexadecimal: if the argument begins with 0x the proceeding characters will be interpreted
|
|
will be interpreted as hex (base 16) for any numeric fields
|
|
for float fields, hexadecimal input results in a precision
|
|
limit (in converting input past the decimal point) of 10^-15</p>
|
|
<p>Character Constant: if the argument begins with a single quote character, the first byte
|
|
of the next character will be interpreted as an 8-bit unsigned integer. If there are
|
|
additional bytes, they will throw an error (unless the environment variable POSIXLY_CORRECT
|
|
is set)</p>
|
|
<h2 id="examples"><a class="header" href="#examples">Examples</a></h2>
|
|
<p>Print a text message:</p>
|
|
<pre><code class="language-shell">printf "{{%s\n}}" "{{Hello world}}"
|
|
</code></pre>
|
|
<p>Print an integer in bold blue:</p>
|
|
<pre><code class="language-shell">printf "{{\e[1;34m%.3d\e[0m\n}}" {{42}}
|
|
</code></pre>
|
|
<p>Print a float number with the Unicode Euro sign:</p>
|
|
<pre><code class="language-shell">printf "{{\u20AC %.2f\n}}" {{123.4}}
|
|
</code></pre>
|
|
<p>Print a text message composed with environment variables:</p>
|
|
<pre><code class="language-shell">printf "{{var1: %s\tvar2: %s\n}}" "{{$VAR1}}" "{{$VAR2}}"
|
|
</code></pre>
|
|
<p>Store a formatted message in a variable (does not work on zsh):</p>
|
|
<pre><code class="language-shell">printf -v {{myvar}} {{"This is %s = %d\n" "a year" 2016}}
|
|
</code></pre>
|
|
<blockquote>
|
|
<p>The examples are provided by the <a href="https://tldr.sh">tldr-pages project</a> under the <a href="https://github.com/tldr-pages/tldr/blob/main/LICENSE.md">CC BY 4.0 License</a>.</p>
|
|
<p>Please note that, as uutils is a work in progress, some examples might fail.</p>
|
|
</blockquote>
|
|
|
|
</main>
|
|
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|
<!-- Mobile navigation buttons -->
|
|
<a rel="prev" href="../utils/printenv.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next" href="../utils/ptx.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<div style="clear: both"></div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|
<a rel="prev" href="../utils/printenv.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next" href="../utils/ptx.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
|
|
|
|
<script src="../elasticlunr.min.js"></script>
|
|
<script src="../mark.min.js"></script>
|
|
<script src="../searcher.js"></script>
|
|
|
|
<script src="../clipboard.min.js"></script>
|
|
<script src="../highlight.js"></script>
|
|
<script src="../book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|