Recursively delete hidden directory & its files?

5,548

It sounds like you want something like this (although it's not clear what you mean when distinguishing "iterative command" from "recursive command", since rm -rf is both recursive and iterative):

find . -type d -name '.[^.]*' -prune -exec echo rm -rf {} +

Once you're happy, remove echo from the option arguments to -exec to remove the listed directories.

Share:
5,548

Related videos on Youtube

Supravat Mondal
Author by

Supravat Mondal

Updated on September 18, 2022

Comments

  • Supravat Mondal
    Supravat Mondal over 1 year

    I want to delete all hidden directoris from a directory and its sub-directory. I also use rm -rf .directory_name this command is iterative command I want to a recursive command. Please anybody help me??

  • unigeek
    unigeek about 3 years
    I'd upvote that again if I could. Great answer!