Linux Commands Helper
💬 Your AI-powered Linux assistant
printf Command - Format and Print Data
printf is used to format and print data according to a specified format. It is more powerful and flexible than echo
, supporting C-style format specifiers.
Syntax
printf FORMAT [ARGUMENT]...
Examples
printf "Hello, %s!\n" world
Print formatted text with a string placeholder.
printf "%d + %d = %d\n" 2 3 5
Print formatted numbers.
Notes
- Supports many C-style format specifiers (e.g.,
%s
,%d
,%f
). - Does not automatically add a newline unless specified in the format string.
- Preferred over
echo
for precise formatting.