What I want to happen is delete non-images in assets/uploads
folder but skip the uploads
folder if the parent folder is not assets
folder.
site1.dev/assets/uploads (delete non-images)
site2.dev/assets/uploads (delete non-images)
site3.dev/assets/uploads (delete non-images)
site4.dev/uploads (skip deletion)
site5.dev/assets/uploads (delete non-images)
This is the code that I used find assets/uploads -name "*.php" -type f -print0 | xargs -0 /bin/rm -f
find assets/uploads -name "*.php" -type f -print0 | xargs -0 /bin/rm -f
but it tedious to run this code each site.
Thank you in advance.
To delete "none-images" as described, you need to first discover the image extensions that are being used and ignore them with find through the -not flag
find ./assets/uploads -type f -not /assets/uploads/*.img -not /assets/uploads/*.jpeg -delete
Answer to my own quesion find. -path '*/assets/uploads/*.php' -type f -delete
find. -path '*/assets/uploads/*.php' -type f -delete
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.