Where to find printf formatting reference?

5,137

As the man page references the C format specifications, you may want to explore it to get the details. E.g. here: http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html

If you insist on having the offline reference, you might want to install the corresponding man pages pack for C lib, so that you could see man 3 printf. This man page is a part of man-pages-2.39-15.el5 package on an old RHEL nearest to me.

Share:
5,137

Related videos on Youtube

l0b0
Author by

l0b0

Author, The newline Guide to Bash Scripting (https://www.newline.co/courses/newline-guide-to-bash-scripting). Hobby (https://gitlab.com/victor-engmark) & work software developer.

Updated on September 18, 2022

Comments

  • l0b0
    l0b0 over 1 year

    Where is the offline reference of the format specifiers (e.g., %i, %s) which are supported by the Bash/system printf command? I've looked in help printf, man 1 printf and man 3 printf without luck.

    man 1 printf mentions says it supports

    %% a single %

    %b ARGUMENT as a string with `\' escapes interpreted, except that octal escapes are of the form \0 or \0NNN

    and all C format specifications ending with one of diouxXfeEgGcs, with ARGUMENTs converted to proper type first. Variable widths are handled.

    The character list is useful, but doesn't explain the exact semantics of each format specification.

    • YoloTats.com
      YoloTats.com over 11 years
      The printf entry in man bash refers to man 1 printf and contains additional format specifiers like %b, %q etc.
  • l0b0
    l0b0 over 11 years
    I missed it in man 3 printf before - Format specifiers are called "conversion specifiers" there, and are not listed with the percent sign in front.
  • Richard Fortune
    Richard Fortune over 11 years
    Just to make it explicit: the shell printf command supports only a subset of the specifiers detailed in man 3 printf.