One thing that always bugged me:
touch a
rm a
ok, it works as expected
mkdir a
rm a
will require -r to work; but I don't understand what is recursive in this? if the folder is empty, there is nothing recursive about it. I would expect rm a to try to remove a, and fail if it's not empty and rm -r to recursively the contents of a.
why is is this like that?
Edit: this question has been flagged as a duplicate of a totally irrelevant question. My question can be summed as: Why do I need a recursive flag to perform a non recursive operation: mkdir a, rm -r a has nothing recursive about it. And this is not related to the other question which is about why rm is not recursive by default.
rmdir
. – Ulrich Schwarz Nov 07 '19 at 13:42rm
is one of the basic commands and they usually also strive for speed. Declining removal for a directory in non-recursive mode is quicker than checking if a directory had entries for every option. Also the general behavior would be IMHO less straight forward ->rm *
== removes all files and directories but only if they are empty vs.rm *
== removes all files and files only – FelixJN Nov 07 '19 at 14:16-r
:p – jesse_b Nov 07 '19 at 14:21