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

Time:12-07

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

CodePudding user response:

The below command should exclude the resources dir,

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