`cp`: `-r` or `-R`?

2 min read Original article ↗

blog - git - desktop - contact


2026-09-30

A question like this recently came up again. I once tried to find an answer, but only posted it in some "forum" a decade ago, and I think it's worth saving this little bit of trivia from digital nirvana.

Nowadays, there's no difference between the two options in GNU coreutils. The current manual page says:

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

Was that always the case?

Let's look at the first commit in GNU coreutils (1992). In src/cp.c, we have this:

case 'r':
    flag_recursive = 1;
    flag_copy_as_regular = 1;
    break;

case 'R':
    flag_recursive = 1;
    flag_copy_as_regular = 0;
    break;

So, back then, there was indeed a difference. But that was 34 years ago. Is that still relevant today? Probably not, because ten years later, in 2002, both options got merged and nobody™ still runs coreutils from 24 years ago.

What about other systems?

OpenBSD 7.9 lists only -R in the manual and strongly discourages the use of -r. It does mention, though, that it still behaves differently than -R. Skim through the code and you can spot a few differences (search for Rflag and rflag).

NetBSD 11: Dito, manual page and code like OpenBSD.

The advantage of -R is that it's more consistent across utilities. For example, chown knows -R -- but not -r. POSIX acknowledges this as well and recommends -R:

Earlier versions of this standard included support for the -r option to copy file hierarchies. The -r option is historical practice on BSD and BSD-derived systems. This option is no longer specified by POSIX.1-2024 but may be present in some implementations. The -R option was added as a close synonym to the -r option, selected for consistency with all other options in this volume of POSIX.1-2024 that do recursive directory descent.