Skip to content
Advertisement

How to print a string AFTER the date in Linux Terminal?

I want to type a one-line command in Linux that will print the date followed by a string to the Terminal. For example, “… is today’s date.” This is what I tried.

MyComputer:~ me$ date | xargs echo " is today's date."

However, this printed ” is today’s date. Sat Feb 20…”

I thought reversing the order would help, but this only printed the date.

MyComputer:~ me$ echo " is today's date." | date | xargs echo

Conversely, my third attempt only printed ” is today’s date.” without the date.

MyComputer:~ me$ date | xargs echo | echo " is today's date."

I am out of ideas. Short of multiple commands, using file input, or even paraphrasing it as “Today’s date is…” how can I get my desired output?

Advertisement

Answer

Try this:

echo "`date` is today's date."
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement