builtin

Bash printf — formatted output

Writes formatted text to standard output, or assigns it with -v. %s inserts a string and \n in the format inserts a newline. The format may be reused for additional arguments. Keep untrusted text in data arguments, not in the format. This entry focuses on fixed text formats; advanced conversions and -v behavior will be expanded later.

Formal Syntax & Structure

bash syntaxbash
printf [-v var] format [arguments]

Parameters & Attributes

NameTypeDescription
formatstringFormat string interpreted by printf.
argumentsstring listValues consumed by conversion specifications.
-v varoptionAssign the formatted result to a variable instead of writing to stdout.

Return Value

exit status

0 on success; nonzero on a formatting, assignment or output failure.

Working Example

Example Snippetbash
printf '%s\n' 'Ready'
Bash Reference