我正在尝试列出早于 x 天的目录(但不是文件)。我使用下面的命令来做到这一点。但它列出了目录和文件。谁能帮我解决它?谢谢。
find /path/to/base/dir/* -type d -ctime +10 -exec ls {} \;
我正在尝试列出早于 x 天的目录(但不是文件)。我使用下面的命令来做到这一点。但它列出了目录和文件。谁能帮我解决它?谢谢。
find /path/to/base/dir/* -type d -ctime +10 -exec ls {} \;
首先测试是否一切正常:
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
尝试这个
find /path/to/base/dir -maxdepth 1 -type d -ctime +10 -exec rm -r {} \;