Find empty directories

Shell utility Reference ↗

Find empty directories in the current directory and all its subdirectories, including hidden ones.

find . -type d -empty  

-type d selects directories. -empty matches directories with no entries. A directory containing an empty subdirectory is not itself empty. The starting directory . can also appear if it is empty.

To find empty regular files instead, change -type d to -type f:

find . -type f -empty  

Both commands list matches without removing anything. They work with GNU find on Linux and the built-in macOS find. Symbolic links are not followed by default.

To limit the directory search to the starting directory and its direct children:

find . -maxdepth 1 -type d -empty