Skip to content

Comment on Linux Sysadmin/DevOps Interview Questionsparent

Comments

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?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.