Search code examples
bashunixdirectory

How to list non-empty subdirectories on linux?


I have a directory containing multiple subdirectories. I want to list only those subdirectories that contain at least one file. How can I do that?


Solution

  •  find . -mindepth 1 -maxdepth 1 -not -empty -type d
    

    will give you all nonempty directories. If you want to exclude directories that contain only other directories (but no files), one of the other answers might be better...