问题描述
我有一个有82000个文件和目录的日志文件目录(大约一半)。我需要删除所有的文件和目录这是超过3天。
在一个有37000个文件的目录中,我可以这样做:
find * -mtime +3 -exec rm {} \;
但是有82000个文件/目录,我得到错误:
如何解决此错误,以便我可以删除所有超过3天的文件/目录? 解决方案
我需要删除所有的文件和目录这是超过3天。
在一个有37000个文件的目录中,我可以这样做:
find * -mtime +3 -exec rm {} \;
但是有82000个文件/目录,我得到错误:
如何解决此错误,以便我可以删除所有超过3天的文件/目录? 解决方案
删除和目录中的所有文件: >找到。 -mtime +3 | xargs rm -Rf
或者,更符合OP的原始命令:
find。 -mtime +3 -exec rm -Rf - {} \;
I've got a log file directory that has 82000 files and directories in it (about half and half).
I need to delete all the file and directories which are older than 3 days.
In a directory that has 37000 files in it, I was able to do this with:
find * -mtime +3 -exec rm {} \;
But with 82000 files/directories, I get the error:
How can I get around this error so that I can delete all files/directories that are older than 3 days?
To delete all files and directories within the current directory:
find . -mtime +3 | xargs rm -Rf
Or alternatively, more in line with the OP's original command:
find . -mtime +3 -exec rm -Rf -- {} \;
这篇关于如何删除所有超过3天的文件,当“参数列表太长”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!