使用 find 命令删除批处理文件中超过 30 天的文件时,如何排除多个子目录(相同的目录名称)?

How to exclude multiple subdirectories (same directory name) when using find command to delete files older than 30 days in a batch file?

给定以下 linux 目录结构,我将如何跳过每个排除目录 (/assess),以删除整个目录结构其余部分超过 30 天的文件?

感谢您的协助...

/mnt/nfsmountpoint/location1/appliance1
/assess
/discover
/bkup
/mnt/nfsmountpoint/location1/appliance2
/assess
/discover
/bkup
etc...

我拼凑了一个答案和证据::(我的星号 * 没有显示抱歉)

运行 来自 /mnt/nfsmountpoint/ 目录。

find .// -not -path "/assess/" -type f -mtime +30 -delete

验证:: 它会跳过目录吗?: 找到 .// -not -path "/assess/" -type f -mtime +30 -ls|more

确认没有包含当前月份(2021 年 1 月)的文件?:

find .// -not -path "/assess/" -type f -mtime +30 -ls|grep Jan

有多少space是免费的?:

find .// -not -path "/assess/" -type f -mtime +30 -print0 | du --files0-from=- hc |尾巴-n1

find /path/to/dir -mtime +30 -type f -not -name "*assess*" -delete

在 /path/to/dir 以及子目录中查找文件(-type f)。仅指定超过 30 天前修改过的文件 (-mtime +30),不包括包含“assess”的文件 (-not -name "assess")