0

我正在尝试列出早于 x 天的目录(但不是文件)。我使用下面的命令来做到这一点。但它列出了目录和文件。谁能帮我解决它?谢谢。

find /path/to/base/dir/* -type d -ctime +10 -exec ls {} \;
4

2 回答 2

0

首先测试是否一切正常:

find /path/to/base/dir -type d -ctime +10 -exec ls -d {} \;

当一切正常时:

find /path/to/base/dir -type d -ctime +10 -exec rm -fr {} \;

说明:

ls -d :  list directories themselves, not their contents
rm -f :  ignore nonexistent files and arguments, never prompt
于 2017-01-04T00:23:08.420 回答
0

尝试这个

find /path/to/base/dir -maxdepth 1 -type d -ctime +10 -exec rm -r {} \;
于 2017-01-03T20:56:36.640 回答