Description of problem: after creating a directory, mkdir -p successfully creates again the directory that already exists. Version-Release number of selected component (if applicable): $ rpm -qf /bin/mkdir coreutils-8.12-6.fc16.i686 How reproducible: always Steps to Reproduce: 1.mkdir -p bugz 2.mkdir -p bugz ; echo $? 3. Actual results: Expected results: mkdir will fail, because the directory already exists Additional info: i've also created a file inside the directory, and after mkdir -p the file is still there.
That's expected behavior. Treat -p as "make sure it (and any parent) exists". It's akin to `touch file`. If you want to split the parents vs exists behavior you might want: mkdir -p $(dirname "$dir") mkdir "$dir" cheers.
This great but, where is it documented?
The man page states: -p, --parents no error if existing, make parent directories as needed
I see, i thought it's no error if parents exist :) do you think the man page can be clarified a bit?
Man page probably not, info documentation is intended to be a bit more wordy in such cases. In info you have: `-p' `--parents' Make any missing parent directories for each argument, setting their file permission bits to the umask modified by `u+wx'. Ignore existing parent directories, and do not change their file permission bits. - any missing seems to be quite self explaining to me, but if you prefer adjusted wording, feel free to propose a change...