Name
printf
Synopsis
printfformats[strings] printfoption
Print strings using the specified formats. formats can be ordinary text characters, C-language escape characters, C format specifications ending with one of the letters diouxXfeEgGcs or, more commonly, a set of conversion arguments listed here.
Options
- --help
Print usage information and exit.
- --version
Print version information and exit.
Arguments
- %%
Print a single %.
- %b
Print string with \ escapes interpreted.
- %s
Print the next string.
- %n$s
Print the nth string.
- %[-]m[.n]s
Print the next string, using a field that is m characters wide. Optionally, limit the field to print only the first n characters of string. Strings are right-adjusted unless the left-adjustment flag, -, is specified.
Examples
printf '%s %s\n' "My files are in" $HOMEprintf '%-25.15s %s\n' "My files are in" $HOME
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access