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?


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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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