I've got cpio.gz created with command:
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. How can i achive that?
I've got cpio.gz created with command:
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. How can i achive that?
OK, I've got 2 .gz
files, a.txt.gz
and 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). Now some 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.