To locate empty directories in Linux using the terminal, we will use the find
command with the -empty
option. Here is the working command,
1 |
find . -type d --empty |
The above command will search for empty directories under the specified path /path/to/search
or directory.

We can also use the -print
option to print the names of the empty directories that are found:
1 |
find /path/to/search -type d -empty -print |
By using the -delete
option to delete the empty directories that we are found,
1 |
find /path/to/search -type d -empty -delete |
Note that the find
command is very powerful and has many options and features. You can use the man find
command to get more details about how to use it.
Also Read:
- How To Install PHP In Windows 10
- How to Execute PHP File From Command Line
- XAMPP, Apache – Error: Apache shutdown unexpectedly – Solved
Happy Coding..!