Search code examples
linuxshellunixubunturm

Linux Shell - Delete a folder whose name startwith .git which is a part of inner folders


here is a sample directory structure/tree

main_directory-|- folder1
               |- folder2
               |- folder3
               |- folder4 -|- .git
                           |- my_project
                           |- some_other_files

assume I'm in the main directory.

admin@admin:~/$ cd main_directory
admin@admin:~/main_directory$

here I want to execute some command which will delete all folders whose name starts with .git RECURSIVELY.

What I was trying = rm -r .git* its not working. or may be using someother command, e.g mv but I dont have any clue about that.

problem is I have many such folders and each of them has one or more .git so I cannot go manually in each directory and delete git folder.


Solution

  • find . -name .git -exec rm -r {} \;