3 ms·
Change it to "how to delete the contents of a directory, but keep the directory itself" and it becomes less simple. But even this can lead to an interesting di
by Someone 11y ago
Change it to "how to delete the contents of a directory, but keep the directory itself" and it becomes less simple.
But even this can lead to an interesting discussion. From a CLI, there's quite a few things to consider. Do you need sudo? If not, you shouldn't use it, IMO. Is the directory name dangerous? If so, would rm -rf -- help? Does rm support -- as an argument at all? I wouldn't know. And would it always prevent problems, even with truly weird directory names (with spaces, asterisks, slashes, $HOME, unbalanced quotes)? Of course you shell should tab-complete names and correctly escape them, but should you check your shell (brand and version) first if the name is weird, and know what versions have a known problem?