免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2469 | 回复: 7
打印 上一主题 下一主题

[系统管理] 请教unzip更新timestamp [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-06-10 11:15 |只看该作者 |倒序浏览
请教各位大侠:请问unzip想解压的时候更新文件修改时间为当前时间,应该带什么参数?

论坛徽章:
0
2 [报告]
发表于 2014-06-10 11:44 |只看该作者
本帖最后由 todayhero 于 2014-06-10 11:55 编辑

@karlzheng_cu



没发现有这个参数,可以使用touch命令实现。


  1. touch URFILE
复制代码

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
3 [报告]
发表于 2014-06-10 13:17 |只看该作者
回复 1# karlzheng_cu
希望对你有帮助. 我没试过.
  1.        -D     skip  restoration  of timestamps for extracted items.  Normally,
  2.               unzip tries to restore all meta-information for extracted  items
  3.               that  are supplied in the Zip archive (and do not require privi-
  4.               leges or impose a security risk).  By specifying  -D,  unzip  is
  5.               told  to  suppress  restoration  of  timestamps  for directories
  6.               explicitly created from Zip archive entries.  This  option  only
  7.               applies to ports that support setting timestamps for directories
  8.               (currently ATheOS, BeOS, MacOS,  OS/2,  Unix,  VMS,  Win32,  for
  9.               other unzip ports, -D has no effect).  The duplicated option -DD
  10.               forces suppression of timestamp restoration  for  all  extracted
  11.               entries (files and directories).  This option results in setting
  12.               the timestamps for all extracted entries to the current time.

  13.               On VMS, the default setting for this option is  -D  for  consis-
  14.               tency   with  the  behaviour  of  BACKUP:  file  timestamps  are
  15.               restored, timestamps of extracted directories are  left  at  the
  16.               current  time.   To  enable restoration of directory timestamps,
  17.               the negated option --D should be specified.  On VMS, the  option
  18.               -D  disables timestamp restoration for all extracted Zip archive
  19.               items.  (Here, a single -D on the command line combines with the
  20.               default -D to do what an explicit -DD does on other systems.)
复制代码

论坛徽章:
0
4 [报告]
发表于 2014-06-10 15:19 |只看该作者
todayhero 发表于 2014-06-10 11:44
@karlzheng_cu


很多文件的

论坛徽章:
0
5 [报告]
发表于 2014-06-10 15:19 |只看该作者
q1208c 发表于 2014-06-10 13:17
回复 1# karlzheng_cu
希望对你有帮助. 我没试过.


试了 不行

论坛徽章:
0
6 [报告]
发表于 2014-06-10 15:22 |只看该作者
@karlzheng_cu

很多文件,你就
  1. find ./ | xargs touch
复制代码

论坛徽章:
33
荣誉会员
日期:2011-11-23 16:44:17天秤座
日期:2014-08-26 16:18:20天秤座
日期:2014-08-29 10:12:18丑牛
日期:2014-08-29 16:06:45丑牛
日期:2014-09-03 10:28:58射手座
日期:2014-09-03 16:01:17寅虎
日期:2014-09-11 14:24:21天蝎座
日期:2014-09-17 08:33:55IT运维版块每日发帖之星
日期:2016-04-17 06:23:27操作系统版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-24 06:20:0015-16赛季CBA联赛之天津
日期:2016-05-06 12:46:59
7 [报告]
发表于 2014-06-10 15:24 |只看该作者
回复 5# karlzheng_cu
刚才试了一下, "-DD" 是可以的. 不知道楼主是如何试的呢?

我前面发的man中提到过 -DD 的用法.
  1. [q1208c@host 15:21 /tmp/q1208c.BQgb6]
  2. $ ll
  3. total 32
  4. -rw-rw-r-- 1 q1208c q1208c   0 Jun  6 17:29 a[1-4]b.txt
  5. -rw-rw-r-- 1 q1208c q1208c   0 Jun  6 17:29 a1b.txt
  6. -rw-rw-r-- 1 q1208c q1208c   0 Jun  6 17:29 a2b.txt
  7. -rw-rw-r-- 1 q1208c q1208c   0 Jun  6 17:29 a3b.txt
  8. -rw-rw-r-- 1 q1208c q1208c   0 Jun  6 17:29 a4b.txt
  9. -rw-rw-r-- 1 q1208c q1208c 258 Jun  6 12:38 file1
  10. -rw-rw-r-- 1 q1208c q1208c 847 Jun  7 11:22 file2
  11. -rw-rw-r-- 1 q1208c q1208c 148 Jun  9 16:41 file3
  12. -rw-rw-r-- 1 q1208c q1208c  76 Jun  9 17:25 file4
  13. -rw-rw-r-- 1 q1208c q1208c  84 Jun  9 17:25 file5
  14. -rw-rw-r-- 1 q1208c q1208c 980 Jun 10 09:25 test.beam
  15. -rw-rw-r-- 1 q1208c q1208c 521 Jun 10 09:26 test.erl
  16. -rw-rw-r-- 1 q1208c q1208c 537 Jun 10 08:14 test.erl.org

  17. [q1208c@wangzw 15:21 /tmp/q1208c.BQgb6]
  18. $ zip file1.zip file1
  19.   adding: file1 (deflated 62%)

  20. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6]
  21. $ mkdir temp

  22. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6]
  23. $ cd temp

  24. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6/temp]
  25. $ unzip -DD ../file1.zip
  26. Archive:  ../file1.zip
  27.   inflating: file1                  

  28. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6/temp]
  29. $ ll
  30. total 4
  31. -rw-rw-r-- 1 q1208c q1208c 258 Jun 10 15:22 file1

  32. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6/temp]
  33. $ rm -rf file1

  34. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6/temp]
  35. $ unzip -D ../file1.zip
  36. Archive:  ../file1.zip
  37.   inflating: file1                  

  38. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6/temp]
  39. $ ll
  40. total 4
  41. -rw-rw-r-- 1 q1208c q1208c 258 Jun  6 12:38 file1

  42. [q1208c@wangzw 15:22 /tmp/q1208c.BQgb6/temp]
  43. $
复制代码

论坛徽章:
0
8 [报告]
发表于 2014-06-10 19:35 |只看该作者
q1208c 发表于 2014-06-10 15:24
回复 5# karlzheng_cu
刚才试了一下, "-DD" 是可以的. 不知道楼主是如何试的呢?


以为是 “-D” 参数就行了

谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP