Tip of the Day: Recursively Delete Empty Folders

Stuck with many nested folders, some of which may be empty? Use the following command to quickly find and delete the empty ones:

find . -empty -type d -delete
  • -empty: File is empty and is either a regular file or a directory
  • -type d: directory
  • -delete: Delete files; true if removal succeeded.
Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.
Founder / Fractional CTO

Nicholas Nadeau is a fractional CTO who empowers teams to build innovative, next-generation technologies. Stay informed on cutting-edge hard tech trends - subscribe to my newsletter. Ready to innovate? Discover my services and accelerate your growth.

Related