How To Delete All Dot Files From a Directory In Linux

Have you ever typed this rm -rf .* within a directory on Linux and discovered that .* matches the . .. directories and therefore starts deleting much more than you intended? In order to properly delete the dot files within a directory while still preserving the directory itself, try this: rm -rf .[^.]* && rm -rf ..?* What this will do is ensure that the dot file name has at least one character after the dot and the second rm will do the same for file names that begin with two dots.

If you have any other clever ways to tackle this issue, I'd love to hear from you.