Linux – deleting folders in linux bash

bashlinuxregex

i'm trying to delete in gnu/linux all folders inside another folder that start with a "." (dot), for that i'm using the find utility, this is what i have:

find . -iname ^\..* -exec rm -rf {} \;

but it doesn't do anything :(. I'm already tested the regular expression and works well. Any help please??

thank's a lot for your time.

Best Answer

find uses globbing syntax, and you can use -type d to find just directories:

find . -type d -name '.?*' | vim -

You need to be extremely careful when globbing or using regex to find .hidden files, as you can quite easily pick up . and delete your whole folder, or even worse, match .. and you delete your whole parent folder. Consider the consequences of the following command:

/home/someuser bash$ rm -rf .*
Related Question