NOW=$(date +%Y_%m_%d.%H:%M:%S)
echo "NOW: $NOW"
The goal is to replace the .
between the d
and %
character with a space. How is this performed? Replacing the .
with the space character produces and error.
By using any of the standard quoting mechanisms:
NOW=$(date "+%Y_%m_%d %H:%M:%S")
or
NOW=$(date '+%Y_%m_%d %H:%M:%S')
or
NOW=$(date +%Y_%m_%d\ %H:%M:%S)