Questions
- What is the difference between the
rm -d
andrm -R
commands in Bash? - Which one should I use?
Details
According to the man page for the rm
command:
rm -d
attempts to remove directories as well as other types of files.rm -R
attempts to remove the file hierarchy rooted in each file argument. The -R option implies the -d option.
Now, I am aware of that last statement (-R
implies -d
), which may seem to answer my question. However, I still wonder why both command flags exist in the first place, if they are supposedly identical in what they do.
Furthermore, because I am still in the process of learning Bash, I think it's good to know which option is the preferred choice among Bash programmers (conventionally), and why.
rm
has-d
. Whereas the POSIX standard says thatrm
should behave identically tormdir
when the target is a directory, the BSD version follows the historical behavior ofrm
unless you use-d
. – Spathe-d
option isn't in POSIX, so this question should be tagged for the specific system where the question is directed. – Constitutionalityrm -R
attempts to remove the file hierarchy rooted in each file argument. The -R option implies the -d option. <-Can anybody interpret the word "file argument" in here? and furthermore I don't understand the entire sentence completely.-> "remove the file hierarchy rooted in each file argument". – Bigname