commands

printf — print formatted output

Bash has a printf builtin and GNU Coreutils also provides an external implementation. For fixed text use a constant format with %s and newline, and pass the text separately. Do not treat arbitrary user text as a format string.

Formal Syntax & Structure

linux syntaxlinux
printf FORMAT [ARGUMENT]...

Parameters & Attributes

NameTypeDescription
FORMATstringFormatting template.
ARGUMENTstringValue substituted into the template.

Return Value

text and exit status

Formatted stdout; zero on success, nonzero on failure. Bash-specific extensions may differ from external printf.

Working Example

Example Snippetlinux
printf '%s\n' 'Hello, Linux!'
Linux Reference