I am trying to create a local folder in my local development machine, on Mac OS X Mountain Lion, so I did:

sudo mkdir /Local
sudo chmod 777 /Local
mkdir -p /Local/Foo/Bar/Wah

(note that last line has no sudo) but the last line gives an error:

$ mkdir –p /Local/Foo/Bar/Wah
mkdir: –p: File exists
mkdir: /Local/Foo/Bar: No such file or directory

Is it some sort of bug? I could instead do:

cd /Local
mkdir -p Foo/Bar/Wah

and it works. Why? And if it is for the reason that it tried to mkdir /Local first but can't because the superuser already did it, then won't this be a bug? (that it should just accept the fact that /Local is there and start mkdir from Foo and go down to Bar and Wah).

closed as off-topic by Gilles, Anthon, slm, Zelda, jasonwryan Jan 23 '14 at 19:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Gilles, Anthon, slm, Zelda, jasonwryan
If this question can be reworded to fit the rules in the help center, please edit the question.


You wrote:

  $ mkdir –p /Local/Foo/Bar/Wah
  mkdir: –p: File exists

After squinting my eyes, real hard, I see that the dash before the "p" isn't really a "-" but a "–" (as so called "en-dash"). I'd guess that there's now a directory called "–p" ("en-dash p") in your $PWD and instead of calling mkdir with -p ("minus-p") you called just mkdir. Confusing, yes. Example:

$ mkdir –p foo                        ### ok, that went through.
$ mkdir –p foo
mkdir: cannot create directory ‘–p’: File exists
mkdir: cannot create directory ‘foo’: File exists

$ ls -ldgo -- *p foo
drwxrwxr-x. 2 4096 Jan 22 19:49 foo
drwxrwxr-x. 2 4096 Jan 22 19:49 –p

Now we have two directories there, foo and en-dash-p - mkdir was never called with -p ("minus-p").

Maybe you copied the mkdir -p command from somewhere else, where -p ("minus-p") was really an en-dash, maybe a Word document or a blog with weird fonts, this happens sometimes.

  • I see why that issue is now. The person didn't update the docs in a wiki at first. For simplicity, he wrote it in Microsoft Word first, and that's how the "em dash" creeped in. – 太極者無極而生 Jan 23 '14 at 22:34

If you need to work for a while in this directory prefer use :

chown -R username.staff /Local

instead of chmod.

Like this all subdirectory will belongs to you. I did same commands on my Mac and all went well. Check in console.app if you see something about these directories.

Not the answer you're looking for? Browse other questions tagged or ask your own question.