Aiden Yeomin Nam
Aiden Yeomin Nam

Reputation: 335

Is there any difference between rm -r and rm -R?

Title is Description.
I just wonder there is any difference between rm -r and rm -R.

Linux man description is seemed like they are totally same(and one more, --recursive), but many people use -r and -R like they aren't same.

So I want to know about not only its functional difference but its practical(or conventional) difference.
Could anyone let me know about this?

Upvotes: 4

Views: 6544

Answers (4)

Hamza Riz
Hamza Riz

Reputation: 9

The two options are equivalent, by default, rm does not remove directories. And by using the --recursive (-r or -R) option to remove each listed directory, too, along with all of its contents.

Upvotes: 0

Stephen C
Stephen C

Reputation: 718678

According to the OpenGroup / POSIX specification for rm, the -r and -R options are equivalent.

Source: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/rm.html

This probably applies to all modern UNIX / Linux variants.

But it wasn't always that way:

The reason for adding -R was for compatibility with other commands that use -R to mean recursive. (For example chmod ... where -r means "remove read permission".)

Upvotes: 5

Harijith R
Harijith R

Reputation: 349

Its the same.

# rm --help | grep directories.
  -r, -R, --recursive   remove directories and their contents recursively
  By default, rm does not remove directories.  Use the --recursive (-r or -R)

Upvotes: 1

Dominique
Dominique

Reputation: 17493

The man-page mentions:

-r, -R, --recursive
       remove directories and their contents recursively

So, at least on my machine, it's the same.

Upvotes: 0

Related Questions