Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

The below command should exclude the resources dir,

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading