Name
printf
Synopsis
printf [-v
var
]format
[val
...]
Format the specified values according to the format format and write them to standard output. The possible format character strings are those of the ANSI C printf function plus several additional strings.
Option
- -v var
Write output to the variable var instead of standard output.
Additional format strings
- %b
Expand escape sequences in strings (e.g., \t to tab, and so on).
- %q
Print a quoted string that can be reread later on.
Example
$date
Reformat date/time Fri May 15 15:39:42 EDT 2009 $printf "%(It is now %m/%d/%Y %H:%M:%S)T\n" "$(date)"
It is now 05/15/2009 15:40:10
Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.