我需要查找不早于 30 天的目录,然后按日期(从最新到最旧)对它们进行排序。 这是我的命令:
find /tmp/logs/ -maxdepth 1 -mindepth 1 -type d -mtime -30
问题显然是排序部分:)
最佳答案
如果只有“几个”目录,您可以将 find
的输出通过管道传递给 xarg ls -t
,例如:
find /tmp/logs/ -maxdepth 1 -mindepth 1 -type d -mtime -30 | xargs ls -td1
关于linux - 查找和排序目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5581250/