PRINTF(1)

๐Ÿ’… PRINTF(1) โ€” the User Commands era โœจ

okay so bestie, welcome to printf(1) โ€” literally one of the User Commands girlies, living in the GNU coreutils house ๐Ÿ ๐Ÿ’–. She formats and prints data, she's been doing it since forever, and she ate. No cap.


๐ŸŒธ NAME ๐ŸŒธ

printf โ€” format and print data, periodt ๐Ÿ’ซ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

printf FORMAT [ARGUMENT]...
printf OPTION

โœจ DESCRIPTION โœจ

So basically: you print your ARGUMENT(s) according to FORMAT ๐Ÿ’…, OR you just execute according to OPTION like a lazy queen ๐Ÿ‘‘:

  • --help โ€” display this help and exit ๐Ÿซถ
  • --version โ€” output version information and exit ๐ŸŒˆ

FORMAT controls the output, exactly like in C printf. The interpreted sequences are (memorize these, fr fr ๐Ÿ˜ญ):

  • \" โ€” double quote
  • \\ โ€” backslash
  • \a โ€” alert (bell) ๐Ÿ””
  • \b โ€” backspace
  • \c โ€” produce no further output ๐Ÿ›‘ (she's done talking)
  • \e โ€” escape
  • \f โ€” form feed
  • \n โ€” new line
  • \r โ€” carriage return
  • \t โ€” horizontal tab
  • \v โ€” vertical tab
  • \NNN โ€” byte with octal value NNN (1 to 3 digits)
  • \xHH โ€” byte with hexadecimal value HH (1 to 2 digits)
  • \uHHHH โ€” Unicode (ISO/IEC 10646) character with hex value HHHH (4 digits)
  • \UHHHHHHHH โ€” Unicode character with hex value HHHHHHHH (8 digits)

and also:

  • %% โ€” a single %
  • %b โ€” ARGUMENT as a string with '\' escapes interpreted, except that octal escapes should have a leading 0 like \0NNN
  • %q โ€” ARGUMENT is printed in a format that can be reused as shell input, escaping non-printable characters with the POSIX $'' syntax

plus all the C printf(3) format specifications ending with one of diouxXfaAeEgGcs, with ARGUMENTs converted to proper type first ๐Ÿ’–. FORMAT is reused to convert all specified arguments โ€” she doesn't get tired, she just loops ๐Ÿ”. The table below shows the supported conversion specifiers, with examples including usage of width, precision, and flags:

  • %s โ€” shell format example '[%10s]' 'left pad' โ†’ output [ left pad]
  • %s โ€” shell format example '[%-10s]' 'right pad' โ†’ output [right pad ]
  • %c %s โ€” shell format example '%c %.3s' un unibyte โ†’ output u uni
  • %d %i โ€” shell format example "%'d ;%04i" 1234 '-1' โ†’ output 1,234 ;-001
  • %o โ€” shell format example '%#o' $((2#110100100)) โ†’ output 0644
  • %u โ€” shell format example '%u' 0xFFFFFFFF โ†’ output 4294967295
  • %x โ€” shell format example '0x%08x' 11259375 โ†’ output 0x00abcdef
  • %a %f โ€” shell format example '%1$a %1$f' 0.0009765625 โ†’ output 0x8p-13 0.000977
  • %e %f โ€” shell format example '%1$e %1$f' 123.456789 โ†’ output 1.234568e+02 123.456789
  • %g โ€” shell format example '%1$g %1$.2g' 1.2345678e3 โ†’ output 1234.57 1.2e+03
  • %b โ€” shell format example '%bfoo' 'bar\cbaz' qux โ†’ output bar
  • %q โ€” shell format example '%q ' 'a' \;b $'c\n' โ†’ output a ';b' 'c'$'\n'
๐Ÿšจ bestie heads up: your shell may have its own version of printf, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports. iykyk ๐Ÿ’€

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by David MacKenzie. (iconic behavior, we stan ๐Ÿซถ)


๐Ÿ› REPORTING BUGS ๐Ÿ›


Copyright ยฉ 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. (so like, she's free, but she's not gonna hold your hand, bestie ๐Ÿ˜ญ)


๐ŸŒˆ SEE ALSO ๐ŸŒˆ

Full documentation <https://www.gnu.org/software/coreutils/printf> or available locally via: info '(coreutils) printf invocation'


and that's the whole page, diva ๐Ÿ’…โœจ this was GNU coreutils 9.12, dated September 2026, and yes she's giving User Commands main character energy the entire time ๐ŸŒธ๐Ÿฆ‹ โ€” now go format something, bestie, you got this fr fr ๐Ÿ’–

๐Ÿ“ฆ where this page comes from