I wanted to run a bunch of mkdir commands to create folders:

mkdir -p mydir/animals/mammals/{platypus,bat,dog}
mkdir -p mydir/animals/reptiles/{snakes,crocodile,lizard}
mkdir -p mydir/colors/basic/{red,blue,green}
mkdir -p mydir/colors/blended/{yellow,orange,pink}
mkdir -p mydir/shape/{circle,square,cube}

While running these, I am getting the error

mkdir : invalid option -- 'R'

What is wrong here and how can I fix it?

  • Looks quite strange. Can you isolate the actual command causing the error by running each separately? – Byte Commander May 19 '17 at 8:52
  • Are these the exact commands you are running? The only time that error should occur is if you have a letter 'R' after the p – Tim May 19 '17 at 10:07

There are some possibilities.

  1. /usr/bin/mkdir was replaced by another 'mkdir'.
  2. mkdirwas defined as alias.
  3. mkdir was defined as bash function.

Please look it up on bash command line.

type mkdir

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.