Bash - printf (Builtin command)

Bash Liste Des Attaques Ovh

About

printf in Bash is a builtin command that writes the formatted arguments to the standard output under the control of the format.

Syntax

printf [-v var] format [arguments]

where

  • format is a character string which contains three types of objects:
    • plain characters, which are simply copied to standard output,
    • character escape sequences, which are converted and copied to the standard output,
    • and format specifications, each of which causes printing of the next successive argument.
  • -v option causes the output to be assigned to the variable var rather than being printed to the standard output.

Format

In addition to the standard printf%281%29 formats, %b causes printf to expand backslash escape sequences in the corresponding argument (except that \c terminates output, backslashes in \', \“, and \? are not removed, and octal escapes beginning with \0 may contain up to four digits), and %q causes printf to output the corresponding argument in a format that can be reused as shell input.

The format is reused as necessary to consume all of the arguments. If the format requires more arguments than are supplied, the extra format specifications behave as if a zero value or null string, as appropriate, had been supplied. The return value is zero on success, non-zero on failure.

Example

var=$'hello Nico\nHello Nico!'
printf "$var\n"
hello Nico
Hello Nico!

Documentation / Reference





Discover More
Bash Liste Des Attaques Ovh
Bash - Builtin Commands

builtin refers to: a builtin command. See or to the specific builtin command. See (useful when defining a function whose name is the same as a shell builtin) The builtin command execute the specified...
Bash Liste Des Attaques Ovh
Bash - Echo (Built-in Command)

Echo in bash. Echo accepts an argument (a literal string or a variable) as standard input, and echoes it back to the terminal as standard output. In Bash, it's available as: the builtin bash command...



Share this page:
Follow us:
Task Runner