printf
Format and print data.
Write the formatted arguments to the standard output under the control
of the format.
SYNTAX printf format [argument]... printf --help printf --version OPTIONS The format characters and their meanings are: \" double quote \0NNN character with octal value NNN (0 to 3 digits) \\ backslash \a alert (BEL) \b backspace \c produce no further output \f form feed \n new line \r carriage return \t horizontal tab \v vertical tab \xNNN byte with hexadecimal value NNN (1 to 3 digits) \uNNNN character with hexadecimal value NNNN (4 digits) \UNNNNNNNN character with hexadecimal value NNNNNNNN (8 digits) %% a single % %b ARGUMENT as a string with `\' escapes interpreted %Wd Integer `W' digits wide xxxx %W.De Scientific notation x.xxxx e nnn. float, double %W.Df Fixed format xx.xxxx. float, double %W.Dg Variable `W' digits wide,`D' decimals xxxx.xx %q Output the corresponding argument in a format that can be reused as shell input %s Character string char and all C format specifications ending with one of diouxXfeEgGcs, with ARGUMENTs converted to proper type first. Variable widths are handled. e.g. `\0ooo' = an octal number, `\xhhh' = a hex number
The format is a character string which contains three types of objects:
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.
Examples $ printf "Two separate\nlines\n" # Using \n to start a new line Two separate lines printf "Hello, $USER.\n\n" # Text followed by variable $USER printf "Distance = %5d Miles" $distance # Display an integer variable Distance = 27 Miles # Print text interspersed with command results printf "This is `uname -s` running on a `uname -m` processor.\n\n"
"I really look with commiseration over the great body of my
fellow citizens who, reading newspapers, live and die in the belief that they
have known something of what has been passing in their time" - H.
Truman
Related Linux Bash commands:
cat - Display the contents of a file
less - Display output one screen at a time
more - Display output one screen at a time
Equivalent Windows XP commands:
ECHO - Display message on screen