Why `cp -r` and `cp -R` Are No Longer the Same

cp: -r or -R?

A deep dive into the history of the `cp` command reveals that `-r` and `-R` once had distinct meanings. In the first GNU coreutils commit from 1992, `-r` copied files as regular files while `-R` did not. The options were merged in 2002, but other systems like OpenBSD and NetBSD still treat them differently. POSIX now recommends `-R` for consistency.

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.
  1. bariumbitmap

    This blog post is odd because it keeps on hinting about a difference between `-r' and `-R' and links to the source code but never actually says what it is. I'll quote the OpenBSD manual that the post mentions but does not link to for some reason:

    > Historic versions of the cp utility had an -r option. This implementation supports that option; however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links or FIFOs.

    https://man.openbsd.org/cp

  2. spijdar

    > nobody™ still runs coreutils from 24 years ago.

    Sprite 2.077 pc386

    Welcome to Sprite

    root@cherimoya [1] # cp --version

    GNU fileutils 3.9

    root@cherimoya [2] # cp --help | grep recurs

    -r copy recursively, non-directories as files

    -R, --recursive copy directories recursively

    root@cherimoya [3] #

    I'll take the honorary title of nobody ;-)

  3. mkl

    -a

    Not sure why you wouldn't want to preserve timestamps, links, etc. by default.

  4. xrd

    I really wish there was a way to know if LLMs hallucinate these switches incorrectly, like I do.

    Feels like this would be exactly the kind of thing they would get wrong. Fur exactly, the training set isn't trained to know the context of execution (FreeBSD vs macos vs Linux), right?

  5. bsoqk

    It's "ditto", not "dito"

More from this day

2026-10-03