简体   繁体   中英

How to zip files using last modified date and time using shell command in linux

I am trying to zip files using last modified date and time with following shell command in linux.

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

Eg

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

It does not works. it takes whole day files.

Following the man page you need to use the time format mmddyyyy . The command should look like this:

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

which gives (today):

zip -rt 03242015 destination.zip source_documents

由于zip -t不会考虑一天中的时间,因此让我们find工作吧,例如

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM