Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

bash

shell

rm

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?

like image 994
Aiden Yeomin Nam Avatar asked Oct 18 '25 11:10

Aiden Yeomin Nam


2 Answers

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 -R option did not exist in v5 UNIX; see here, page 97.
  • Or in v7 UNIX; see https://www.unix.com/man-page/v7/1/rm/.
  • It apparently was introduced in 4.2bsd; see https://linuxgazette.net/issue49/fischer.html ... as meaning the same as -r.

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".)

like image 71
Stephen C Avatar answered Oct 21 '25 02:10

Stephen C


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)
like image 24
Harijith R Avatar answered Oct 21 '25 03:10

Harijith R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!