【问题标题】:How to zip files using last modified date and time using shell command in linux如何在linux中使用shell命令使用最后修改的日期和时间压缩文件
【发布时间】:2015-03-24 12:08:19
【问题描述】:

我正在尝试使用最后修改的日期和时间在 linux 中使用以下 shell 命令压缩文件。

zip -rt $(date +"%Y-%m-%d:%H:%M:%S") destination.zip source_documents

例如

zip -rt 2015-03-24:17:14:39 destination.zip source_documents

它不起作用。它需要一整天的文件。

【问题讨论】:

  • 其实你的问题是我的答案。我需要复制一整天的文件,它就像一个魅力:)

标签: linux shell


【解决方案1】:

按照手册页,您需要使用时间格式mmddyyyy。该命令应如下所示:

zip -rt $(date +"%m%d%Y") destination.zip source_documents

这给了(今天):

zip -rt 03242015 destination.zip source_documents

【讨论】:

  • 我想使用日期和时间压缩文件。
【解决方案2】:

由于zip -t 不考虑一天中的时间,让我们find 完成这项工作,例如。 g.

find source_documents -newermt "2015-03-24 17:14:38" | zip -@ destination

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多