[英]Extract cpio.gz with two archives inside
I've got cpio.gz created with command: cat a.cpio.gz b.cpio.gz > c.cpio.gz
我已经使用以下命令创建了cpio.gz:
cat a.cpio.gz b.cpio.gz > c.cpio.gz
Now i want to extract this c.cpio.gz file to b.cpio.gz and a.cpio.gz. 现在,我想将此c.cpio.gz文件提取到b.cpio.gz和a.cpio.gz。 How can i achive that?
我怎样才能做到这一点?
OK, I've got 2 .gz
files, a.txt.gz
and b.txt.gz
. 好的,我有2个
.gz
文件, a.txt.gz
和b.txt.gz
Then: 然后:
$ cat a.txt.gz b.txt.gz > c.txt.gz
$ hexdump -C c.txt.gz
00000000 1f 8b 08 08 f7 a3 00 59 00 03 61 2e 74 78 74 00 |.......Y..a.txt.|
00000010 4b 2c 4e e1 4a 24 80 01 a9 66 ae 58 24 00 00 00 |K,N.J$...f.X$...|
00000020 1f 8b 08 08 01 a4 00 59 00 03 62 2e 74 78 74 00 |.......Y..b.txt.|
00000030 2b 2c 4f e5 2a 24 0a 73 a5 72 01 00 70 24 d5 0a |+,O.*$.s.r..p$..|
00000040 2d 00 00 00 |-...|
See those 1f 8b 08
starting at 0x00 and 0x20, they are the BOF markers for .gz
files ( based on the article I referred to in the OP's comments ). 看到那些从0x00和0x20开始的
1f 8b 08
,它们是.gz
文件的BOF标记( 基于我在OP注释中引用的文章 )。 Now some awk: 现在一些awk:
$ awk '
BEGIN { RS="\x1f\x8b\x08"; ORS="" } # set the marker to RS
NR==2 { print RS $0 > "a2.txt.gz" } # output the marker and what's after first marker
NR==3 { print RS $0 > "b2.txt.gz" } # output the marker and what's after the second
' c.txt.gz
Produces 2 files and based on my diff
they are identical to original files. 产生2个文件,根据我的
diff
它们与原始文件相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.