add this following or preceding your line `date "+%Y-%m-%d"`
e.g. 2016-04-26
in your code printf "this is the output\t`date "+%Y-%m-%d"`"
will read as:
this is the output 2016-04-26
you can use this with echo
too
you can do others like:
`date "+%b%d"`
e.g. Apr-26
for other formats check man date
additional info:
` (Back Quotes) : Command Substitution
The ` character (found on the key with the ~) is very important when used in shell commands. This ` indicates that command substitution is required wherever it is used. Hence whenever ` is used, whatever part of the command is enclosed by these Backquotes marks would be executed (as if it was the only command) and then the result of that command would be substituted in the original shell command that you typed. The following explains this clearly
Source: http://www.codecoffee.com/tipsforlinux/articles/26-2.html
man date
and read. – DisplayName Apr 25 '16 at 21:06ts
(from moreutils) can do this easily. – Dilawar Feb 22 '21 at 13:58