免费注册 查看新帖 |

Chinaunix

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

可以直接把两个.gz文件cat在一起吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-11-22 18:05 |只看该作者 |倒序浏览
如题!
我有两个比较大的gz文件, 之前我一直都是先解压,再cat,最后gzip,但是这两个文件比较大,如此操作费时,请问能直接把gz文件cat在一起吗?

论坛徽章:
0
2 [报告]
发表于 2011-11-22 18:12 |只看该作者
你不如把两个gz文件tar 起来(不要加压缩的选项),和你说的cat应该是同样效果

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
3 [报告]
发表于 2011-11-22 19:40 |只看该作者
  1. gzcat file1.gz file2.gz |gzip > new.gz
复制代码

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
4 [报告]
发表于 2011-11-22 20:00 |只看该作者
manpage 里专门有一段描述这事儿的

  1. ADVANCED USAGE

  2.        Multiple  compressed  files  can  be concatenated. In this case, gunzip
  3.        will extract all members at once. For example:

  4.              gzip -c file1  > foo.gz
  5.              gzip -c file2 >> foo.gz

  6.        Then

  7.              gunzip -c foo

  8.        is equivalent to

  9.              cat file1 file2

  10.        In case of damage to one member of a .gz file, other members can  still
  11.        be  recovered  (if the damaged member is removed). However, you can get
  12.        better compression by compressing all members at once:

  13.              cat file1 file2 | gzip > foo.gz

  14.        compresses better than

  15.              gzip -c file1 file2 > foo.gz

  16.        If you want to recompress concatenated files to get better compression,
  17.        do:

  18.              gzip -cd old.gz | gzip > new.gz

  19.        If a compressed file consists of several members, the uncompressed size
  20.        and CRC reported by the --list option applies to the last member  only.
  21.        If you need the uncompressed size for all members, you can use:

  22.              gzip -cd file.gz | wc -c

  23.        If  you  wish  to create a single archive file with multiple members so
  24.        that members can later be extracted independently, use an archiver such
  25.        as  tar or zip. GNU tar supports the -z option to invoke gzip transpar-
  26.        ently. gzip is designed as a complement to tar, not as a replacement.


复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP