简体   繁体   中英

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 -delete -not -path "./resources/*"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM