how can I recursively delete empty directories in my home directory?

how can I recursively delete empty directories in my home directory?

The find command is the primary tool for recursive file system operations. Use the -type dexpression to tell find you’re interested in finding directories only (and not plain files). The GNU version of find supports the -empty test, so

$ find . -type d -empty -print

will print all empty directories below your current directory.

Use find ~ -… or find "$HOME" -… to base the search on your home directory (if it isn’t your current directory).

After you’ve verified that this is selecting the correct directories, use -delete to delete all matches:

$ find . -type d -empty -delete


Comments (4)

  • minecraft

    This excellent website certainly has all of the information I wanted concerning this subject
    and didn’t know who to ask.

  • minecraft

    Right now it sounds like Movable Type is the best blogging
    platform available right now. (from what I’ve
    read) Is that what you’re using on your blog?

  • minecraft

    Good day! I just want to give you a big thumbs up for your excellent info you
    have right here on this post. I will be returning to your site for more soon.

  • minecraft

    Hello are using WordPress for your blog platform? I’m new to the
    blog world but I’m trying to get started and set up my own. Do you require any html coding expertise to make your
    own blog? Any help would be greatly appreciated!

Leave a Reply