0

I want to create a folder following the below procedure:

set folder 2017/October/10
mkdir $folder

But this isn't possible and I get the message:

mkdir: cannot create directory '2017/October/10': No such file or directory

I want to include that in script function! I could really use some help!

EDIT: This just can't happen!

muru
  • 197,895
  • 55
  • 485
  • 740
  • Same result. It didn't work. – Teo Protoulis Nov 13 '17 at 02:39
  • 1
    That is not a good name, it will cause problems. You can try mkdir '2017/October/10' but imho better use a different delineate 2017.October.10 for exame – Panther Nov 13 '17 at 02:44
  • 3
    I'd recommend ISO-8601 format for naming files and dirs, so in this case: 2017-10-10 – wjandrea Nov 13 '17 at 02:46
  • 1
    Forward slashes aren't allowed in file or directory names on any variant of Unix (including Linux). Even if individual filesystems support it (and the main ones don't), the operating system doesn't. I'd recommend dashes instead. – thomasrutter Nov 13 '17 at 05:47

1 Answers1

3

The / character is used to separate the different directories, and it fails because the directory 2017 does not yet exist. To create nested directories with the parent directories created automatically, use

mkdir -p 2017/October/10
rlee827
  • 167