Let's say there's a.gz, and b.gz.
假设有a.gz和b.gz.
$ gzip_merge a.gz b.gz -output c.gz
$ gzip_merge a.gz b.gz -output c.gz
I'd like to have this program. Of course,
我想要这个节目。当然,
$ cat a.gz b.gz > c.gz
$ cat a.gz b.gz> c.gz
doesn't work. Because the final DEFLATE block of a.gz has BFINAL, and the GZIP header of b.gz. (Refer to RFC1951, RFC1952) But if you unset BFINAL, throw away the second GZIP header and walk through the byte boundaries of the second gzip file, you can merge it.
不起作用。因为a.gz的最终DEFLATE块具有BFINAL,而b.gz的GZIP头部。 (请参阅RFC1951,RFC1952)但是如果你取消设置BFINAL,抛弃第二个GZIP标头并遍历第二个gzip文件的字节边界,你可以合并它。
In fact, I thought of writing an open source program for this matter, but didn't know how to publish it. So I asked the Joel to be my program manager, and I walked him through my explanation and defense, he finally understood what I wanted to do, but said he was too busy. :(
事实上,我曾考虑为此事编写一个开源程序,但不知道如何发布它。所以我让乔尔成为我的项目经理,我带他完成了我的解释和辩护,他终于明白我想做什么,但说他太忙了。 :(
Of course, I could write one myself and try my way to publish it. But I can't do this alone because my day work belongs to the property of my employer.
当然,我可以自己写一个并尝试发布它。但我无法独自完成这项工作,因为我的日常工作属于我雇主的财产。
Is there any volunteers? We could work as programmer(me), publisher(you) or programmer(you), publisher(me). All I need is some credit. I once implemented a Universal Decompressor Virtual Machine described in RFC3320. So I know this is feasible.
有志愿者吗?我们可以作为程序员(我),出版商(您)或程序员(您),出版商(我)。我所需要的只是一些功劳。我曾经实现过RFC3320中描述的通用解压缩器虚拟机。所以我知道这是可行的。
OR, you could point me to THAT program. It would be very useful for managing log files like merging 365 (day) gzipped log files to one. ;)
或者,你可以指点那个程序。这对于管理日志文件非常有用,例如将365(天)gzip压缩日志文件合并为一个。 ;)
Thanks.
2 个解决方案
#1
33
Of course, cat a.gz b.gz > c.gz doesn't work.
当然,cat a.gz b.gz> c.gz不起作用。
Actually, it works just fine. I just tested it. It's even documented (sort of) in the gzip man page.
实际上,它运作得很好。我刚试过它。它甚至在gzip手册页中记录(有点)。
Multiple compressed files can be concatenated. In this case, gunzip
will extract all members at once. For example:
gzip -c file1 > foo.gz
gzip -c file2 >> foo.gz
Then
gunzip -c foo
is equivalent to
cat file1 file2
#2
4
You could also:
你也可以:
zcat a.gz b.gz > c.txt && gzip c.txt
as long as your Linux/Unix distribution has zcat built in, which most of them do (and you could install it for the ones that do not.)
只要您的Linux / Unix发行版内置了zcat,其中大多数都是这样做的(并且您可以将它安装到那些没有的。)
Alternatively:
zcat a.gz b.gz | gzip -c > c.txt.gz
#1
33
Of course, cat a.gz b.gz > c.gz doesn't work.
当然,cat a.gz b.gz> c.gz不起作用。
Actually, it works just fine. I just tested it. It's even documented (sort of) in the gzip man page.
实际上,它运作得很好。我刚试过它。它甚至在gzip手册页中记录(有点)。
Multiple compressed files can be concatenated. In this case, gunzip
will extract all members at once. For example:
gzip -c file1 > foo.gz
gzip -c file2 >> foo.gz
Then
gunzip -c foo
is equivalent to
cat file1 file2
#2
4
You could also:
你也可以:
zcat a.gz b.gz > c.txt && gzip c.txt
as long as your Linux/Unix distribution has zcat built in, which most of them do (and you could install it for the ones that do not.)
只要您的Linux / Unix发行版内置了zcat,其中大多数都是这样做的(并且您可以将它安装到那些没有的。)
Alternatively:
zcat a.gz b.gz | gzip -c > c.txt.gz