On 10May2020 13:36, Robert Moskowitz <rgm@xxxxxxxxxxxxxxx> wrote:
It is entirely true. The collapsing happens when you _use_ the values:
# all safe and reliable
$ a=$( date +'%a %b %d %T %Y')
$ b=$( date +'%a %b %d %T Y')
$ c=$b
# unquoted use
$ echo $a
Sat May 09 14:37:07 2020
$ echo $b
Sat May 09 14:37:15 2020
$ echo $c
Sat May 09 14:37:15 2020
# quoted use
$ echo "$a"
Sat May 09 14:37:07 2020
$ echo "$b"
Sat May 09 14:37:15 2020
$ echo "$c"
Sat May 09 14:37:15 2020
The variable $b contains the multiple spaces you put in your date
format. But they only survive is you quote the variable when you use
it. [...]
I am having problems taking out the '
You've misread things.
Keep the ' quote, it is needed so that the '+.....' argument remains
_one_ argument to the date command.
We're talking about dropping the " from the "$(...)" part. So change:
currentDate="$(date +'%a %b %d %T %Y')"
into:
currentDate=$(date +'%a %b %d %T %Y')"
which does not need the double quotes because the shell parses
currentDate=$(......) as the assignment because of the punctuation.
Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx