Linux / Unix: Find All Hidden Dot Directories and Delete

To find and delete all hidden directories (directories starting with a dot) in a Linux or Unix system, you can use the following command:

find /path/to/search -name ".*" -type d -exec rm -rf {} \;

Replace /path/to/search with the path to the directory where you want to search for hidden directories.

For example, to find and delete all hidden directories in the home directory of the current user, you can run the following command:

find ~/ -name ".*" -type d -exec rm -rf {} \;

Note: Be careful when using the rm command, as it will permanently delete the files and directories specified. If you want to preview the hidden directories before deletion, remove the -exec rm -rf {} \; part from the command and run it.

Leave a Comment