In an old version of Unix, the
rm command would delete directories if they were empty. From the Research Unix Eighth Edition man page for rm: "If an entry is a directory it is removed only if empty." I like this behaviour, so I've got this alias in my
alias rm='rm -d' I'm using the GNU coreutils version of
rm, in which
rm to go ahead and remove directories if they're empty.
So far so good. This alias allows me to use
rm like the old days. However, I'd like to take it a step further. I'd like
rm to delete a directory even if the directory contains other directories, so long as directories are the only thing there. It doesn't matter how deep the directory structure goes, as long as there aren't any files in there, just empty (once you get to the bottom) directories, I'd like
rm to remove them all.
Could this be written as an alias which would still function as the regular
rm and delete any files passed to it?