linux 取出某两个日期之间的文件

事件:某个文件夹下面有60W+的excel文件(此时想啪啪抽脸,怎么就没分文件夹呢),现需要提取出来3月19日到4月7号的excel。

执行命令:

find /data/excels/ -type f  -newermt '2018-03-19' ! -newermt '2018-04-07' -exec mv {}   /data/old_excels \;

man find :

-newerXY reference
              Compares  the timestamp of the current file with reference.  The reference argument is normally the name of a file (and one of its timestamps is used for the comparison) but it
              may also be a string describing an absolute time.  X and Y are placeholders for other letters, and these letters select which time belonging to how reference is  used  for  the
              comparison.

              a   The access time of the file reference
              B   The birth time of the file reference
              c   The inode status change time of reference
              m   The modification time of the file reference
              t   reference is interpreted directly as a time

              Some  combinations  are invalid; for example, it is invalid for X to be t.  Some combinations are not implemented on all systems; for example B is not supported on all systems.
              If an invalid or unsupported combination of XY is specified, a fatal error results.  Time specifications are interpreted as for the argument to the -d option of GNU  date.   If
              you try to use the birth time of a reference file, and the birth time cannot be determined, a fatal error message results.  If you specify a test which refers to the birth time
              of files being examined, this test will fail for any files where the birth time is unknown.


命令描述:取出2018-03-19之后,2018-04-07之前的文件,并移动到old_excels 文件夹中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值