我有这样一个命令,可以清除我的Android 10手机上所有应用程序3天前的缓存文件:
find /data/data/*/cache -type f -mtime +3 -exec rm -r {} +现在,我要排除文件夹/data/data/org.fdroid.fdroid/cache及其子文件夹。我遇到两个问题
find /data/data/*/cache -type f -not \( -name org.fdroid.fdroid \) -print
(用于-print的测试)
当我缩小到
-path和-name参数(如)时,
find /data/data -path */cache/* -type f -not \( -name org.fdroid.fdroid \) -print
我会遇到错误,比如
查找:错误的arg 'data/cache/backup_stage‘和
-not参数被忽略。
这意味着find不是从命令中定义的根路径开始,而是从电话/的根开始,与我所发现的所有描述相反。
在这里How to exclude a directory in find . command
在这里,Remove only files in directory on linux NOT directories和其他地方,我没有找到解决方案。
我怎么才能在我的手机上做到这一点?
发布于 2022-04-24 04:34:30
我想是这样的。
find /data/data/*/cache -type f -not -path '/data/data/org.fdroid.fdroid/*' -mtime +3 -delete或
find /data/data/*/cache -type f -not -path '/data/data/org.fdroid.fdroid/cache/*' -mtime +3 -deletehttps://stackoverflow.com/questions/71984212
复制相似问题