0

If I execute touch $(date '+%F %T'), I expect one file whose filename comprises the date and time to be created; but instead two files are created: one whose name is the date, and the other whose name is the time:

$ touch $(date '+%F %T')
$ ls -1
12:39:26
2019-03-05

Why is this, and how can I create a file named 2019-03-05 12:39:26 instead, without using an underscore instead of a space?

EmmaV
  • 4,067
  • If you run date '+%F %T' you will see you have two strings. This is like calling touch 12:39:26 2019-03-05. – Freddy Mar 05 '19 at 12:52

1 Answers1

3

Use double quotes:

touch "$(date '+%F %T')"

Related:

Kusalananda
  • 333,661
choroba
  • 47,233