find . -type d -empty command, but that only finds literally empty directories.
What I want to achieve is something a little bit more complex: I want to find empty directories or directories that ONLY have other directories or empty directories, and this rule should be passed on recursively.
So for example, in this directory structure:
It would find
But if at any point in the tree there's a file, for example in this case if there's a file in
1/11/111/file1 then none of them before the file should be returned. So if there's an empty directory
1/11/111/1111/ next to
1/11/111/file1, 1111 should be returned.
The reason I want this is because I want to delete my empty folders.
Now I could probably do that by running
find . -type d -empty -delete over and over again, but I want a way to kind of visualize it before I remove them.
Is this possible?