I have the following file party.txt
that contains something like the following:
Hello Jacky
Hello Peter
Bye Johnson
Hello Willy
Bye Johnny
Hello Mar
If you're open to using Perl:
perl -MPOSIX -lne 'if (/Hello/){ print "$_ " . strftime "%Y-%m-%d",localtime }' party.txt
produces this output
Hello Jacky 2015-10-01
Hello Peter 2015-10-01
Hello Willy 2015-10-01
Hello Mary 2015-10-01
Hello Wendy 2015-10-01
Here's how it works:
-n
loops around every line of the input file, do not automatically print each line
-l
removes newlines before processing, and adds them back in afterwards
-e
execute the perl code
$_
is the current line
-MPOSIX
loads the POSIX module, which includes strftime
localtime
and strftime
prints the time, given the format %Y-%m-%d