Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Interix on Windows for Unix compatibility and am finding the -p argument to mkdir not behaving as I expect:

> which mkdir

> mkdir -p c:\Program Files\
A subdirectory or file -p already exists.
Error occurred while processing: -p.

The SUA man page for mkdir states in part:

     mkdir - make directories

     mkdir [-p] [-m mode] directory_name [...]

     The mkdir utility creates the directories named as operands, in the order
     specified, using mode rwxrwxrwx (0777) as modified by the current

     -p      Create intermediate directories as required.  If this option is
             not specified, the full path prefix of each operand must already
             exist.  Intermediate directories are created with permission bits
             of rwxrwxrwx (0777) as modified by the current umask, plus write
             and search permission for the owner.  Do not consider it an error
             if the argument directory already exists.

Why am I getting error about existing directory even though I passed -p? It seems the -p is not recognized as a flag and instead it is making a directory named -p. How do you pass the -p argument?

share|improve this question
up vote 0 down vote accepted

The windows mkdir was being picked up instead of the Interix one. I avoid the issue by giving full path to Interix's mkdir location. This was needed even though which mkdir gave the Interix one.

share|improve this answer
Perhaps you'd need to fix your PATH variable? – Lie Ryan Feb 25 '13 at 6:51
@Lie Ryan But if it was path, then why did which mkdir show the one I want? – WilliamKF Feb 25 '13 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .