Produce predictable, well-formatted output in shell scripts and terminals. 23.04.2026 | reading time: 2 min If he wants precise, predictable output in scripts or on the terminal, printf delivers fine-grained control over formatting and escape sequences. Aligned columns Format a neat inventory table and see the result immediately: ```bash\nprintf "%-10s %5s %8.2f\n" "Item" "Qty" "Price"\nprintf "%-10s %5d %8.2f\n" "Widget" 7 12.5\nprintf "%-10s %5d %8.2f\n" "Gadget" 123 3.456\n``` Output: ```\nItem Qty Price\nWidget 7 12.50\nGadget 123 3.46\n``` Formatting power Use familiar C-style specifiers like %s, %d, %f, %x and width/precision controls to line up columns; use %b to expand backslash escapes and argument indexing like %1$s to reuse parameters, and prefer `printf "%s" "$var"` to safely print arbitrary data without surprises. Practical choices Prefer printf over echo when portability or exact output is required because echo implementations differ; use printf for error messages, aligned logs, machine-readable lines (with a terminating \0 when needed) and when composing complex format strings in scripts. Next steps Try replacing ad hoc echo calls in a small script with printf, experiment with width and precision, and compare bash builtin printf with /usr/bin/printf to spot subtle differences; then deepen shell skills and consider formal certification like CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities scripting troubleshooting