How do I append the UNIX command date to an echo statement

Doug Smith picture Doug Smith · Feb 2, 2012 · Viewed 95k times · Source

Basically I want to have the terminal output a message followed by the date and time, like "Hi, today is -dateandtime-".

So echo can accomplish the first bit, and date can accomplish the last, but only separately, how can I put them together (in one command) so they output together.

Like

echo hello there

-new command-

date

Does it, but not in one line. Is pipelining the answer?

Answer

jlliagre picture jlliagre · Feb 2, 2012

This will do it:

 echo "Hi, today is $(date)"