I want to create a echo statement in a Bash script that will say "Today is (current date and time)".
so far I've tried:
today=date
echo Today is $today
but no luck
To embed commands into other ones, either wrap them in ``
or in $()
.
Examples:
echo Today is $(date)
echo Today is `date`
the right one is:
today=$(date)
echo Today is $today
In other words, use the variable=$(commands)
syntax, it will save the result of command into variable
and so if you want to printout the what was the result? you can use:
echo $variable
here is the similar example http://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/