printf

Format and print data with precise control over output format.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

printf formats output using format specifiers (like C printf). More predictable than echo — doesn't add a newline by default, handles escape sequences consistently, and supports format strings for aligned output in scripts.

Examples
printf 'Name: %s\nAge: %d\n' 'Alice' 30Formatted multi-line output · explain & risk-check →
printf '%10s %5s\n' 'Host' 'Status'Right-aligned column headers · explain & risk-check →
printf '%.2f\n' 3.14159Print float with 2 decimal places · explain & risk-check →
printf '%b' '\033[32mGreen Text\033[0m\n'Print colored text in scripts · explain & risk-check →
Pro tip

Use printf instead of echo in scripts for portability — echo behavior with -e and escape sequences varies across shells and implementations.

Related
echo tee column
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man printf for your version. Test destructive commands on a non-production system first.