Next: Time Formats, Previous: Escapes, Up: Print File Information
‘-printf’ and ‘-fprintf’ support the following format
directives to print information about the file being processed. The C
printf
function, field width and precision specifiers are
supported, as applied to string (%s) types. That is, you can specify
"minimum field width"."maximum field width" for each directive.
Format flags (like ‘#’ for example) may not work as you expect
because many of the fields, even numeric ones, are printed with %s.
The format flag ‘-’ does work; it forces left-alignment of the
field.
‘%%’ is a literal percent sign. A ‘%’ character followed by
an unrecognised character (i.e., not a known directive or printf
field width and precision specifier), is discarded (but the
unrecognised character is printed), and a warning message is printed
to the standard error output (because it was probably a typo). Don't
rely on this behaviour, because other directives may be added in the
future.
A ‘%’ at the end of the format argument causes undefined behaviour since there is no following character. In some locales, it may hide your door keys, while in others it may remove the final page from the novel you are reading.