printf
Format and print data with C-style format strings for precise output control.
Synopsis
printf FORMAT [ARGUMENT]...
Examples
printf '%s\n' 'hello' 'world'
printf '%-20s %5d\n' 'Alice' 42 'Bob' 37
printf '%x\n' 255
printf '%.2f\n' 3.14159
About printf
The `printf` command format and print data with C-style format strings for precise output control. Text processing commands transform, format, and generate text output.
Linux's philosophy of small composable tools shines here — these commands are designed to be piped together to build complex text-processing workflows. They are indispensable for scripting, log analysis, and data transformation tasks.
The command accepts 0 commonly used flags shown above, though the full set of options is available in the man page (`man printf`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Text Processing Commands
Other commands in the Text Processing category