This simplest of problems just never fails to find a new victim. For whatever reason you want to delete all hidden files in the current directory and subfolders. Without much thinking you just type rm -rf .* Here’s a classic example of one developer giving another developer a terrile advise.

The problem here, of course, is that .* wildcard expands to include .., which is the name-inode map for the parent directory. Thus, if your run rm -rf .* as root from any subfolder, you will wipe out your entire server, including the data on any network mounted shares.

Whenever deleting anything using wildcards, try to limit your destructive abilities as much as possible. For example, the command below will delete hidden files in the current directory without descenting into any subfolders:

The following command will delete hidden folders at the current directory level:

You can control the depth of search by adjusting the maxdepth parameter.

Leave A Reply

Please enter your comment!
Please enter your name here