我有一组快照。每个快照驻留在accountname
文件夹,每个快照被命名为带有日期的格式为:YYYY-MM-DD-accountname
基于文件夹名称检索比日期还早的文件夹
我怎样才能找回“快照文件夹”它是老年人超过2天的名字吗? (该2017-05-*
目录)
文件夹结构,如:
/home/snapshots
/home/snapshots/account1
/home/snapshots/account1/2017-05-01-account1
/home/snapshots/account1/2017-05-02-account1
/home/snapshots/account1/2017-05-03-account1
/home/snapshots/account1/2017-05-04-account1
/home/snapshots/account1/2017-05-05-account1
/home/snapshots/account1/2017-05-06-account1
/home/snapshots/account2
/home/snapshots/account2/2017-05-01-account1
/home/snapshots/account2/2017-05-02-account1
/home/snapshots/account2/2017-05-03-account1
/home/snapshots/account2/2017-05-04-account1
/home/snapshots/account2/2017-05-05-account1
/home/snapshots/account2/2017-05-06-account1
比如......我想列出/home/snapshots/account1/2017-05-01
通过/home/snapshots/account1/2017-05-04
,因为今天是2017年5月6日(美国),和副反之亦然为account2
我想find /home/snapshots/ -type d -mtime +2 -exec -ls -la {} \;
可以做的伎俩,但返回我的所有文件夹旧目录超过2天以上......而加入maxdepth 1
返回任何...
如果你想在删除时间大于2天时使用'find',你实际上要求删除超过2天以前的文件** **(大于2岁,24小时以前)你实际上想要找到/ home -type d -name“snapshots”-mtime +2 -execdir rm -r'{}'+'(使用'execdir'代替'exec',在目标目录中执行效率稍高) –