Bash how to delete all files of multiple extensions excluding one directory



I have this snippet

find . \( -iname \*.ini -o -iname \*.properties -o -iname \*.xml \) -type f -delete

which deletes everything in all subfolders that contains those extensions, which is exactly what I want.

The only change I want to make is now I would like to have this exclude a directory called "Resources/". I want it to delete all noted extension files in all subfolders EXCEPT for Resources directory.

I am not sure how to do this however.

Any and all help is appreciated


The below command should exclude the resources dir,

find . \( -iname \*.ini -o -iname \*.properties -o -iname \*.xml \) -type f -not -path "./resources/*" -delete

Answered By – Ramachandran Rajasekaran

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More