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

Some commands use a lower case r for their recursive flag while others use a capital letter R.

cp -r foo/ bar/

chmod -R 777 foobar/

Is there a reason for this?

share|improve this question
up vote 7 down vote accepted

cp actually accepts both.

From cp --help:

  -R, -r, --recursive          copy directories recursively

For consistency, most shell commands use -R as a recursive flag, probably because they imitate the behavior of ls.

From ls --help:

  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
share|improve this answer
Also, chmod -r is already used to mean something other than recursive! – Darth Android Jun 19 '12 at 18:24

I'm not sure that there's any specific reason to the inconsistancy other than that programmers can choose to use whatever flags they want.

I don't think there's any form of standard for that so it's hard to expect everyone to follow suit.

share|improve this answer
The reason would likely be historical. In the larger Unix world which dates all the way back to the 70s, the recursive switches weren't always there, and some commands already had made use of -r as a switch. Because commands are often used within scripts, there's tremendous inertia associated with backwards compatibility, so these things basically never change - you can add options to a program, but woe be the developer who tries to change long-established functionality. – Stephanie Jun 19 '12 at 18:51

You must log in to answer this question.

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