$ hexdump -C part1.cpio | tail -7
000002d0 2e 0d 0a 09 09 20 20 5b 57 6f 72 64 4e 65 74 20 |..... [WordNet |
000002e0 31 2e 35 5d 0d 0a 0a 00 c7 71 00 00 00 00 00 00 |1.5].....q......|
000002f0 00 00 00 00 01 00 00 00 00 00 00 00 0b 00 00 00 |................|
00000300 00 00 54 52 41 49 4c 45 52 21 21 21 00 00 00 00 |..TRAILER!!!....|
00000310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000400
$ hexdump -C part2.cpio | tail -7
0001da40 46 96 ab f8 ad 11 23 90 32 79 ac 1f 8f ff d9 00 |F.....#.2y......|
0001da50 c7 71 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |.q..............|
0001da60 00 00 00 00 0b 00 00 00 00 00 54 52 41 49 4c 45 |..........TRAILE|
0001da70 52 21 21 21 00 00 00 00 00 00 00 00 00 00 00 00 |R!!!............|
0001da80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
0001dc00
对于cpio二进制存档,好的新内容是预告片具有280字节的固定长度。 因此,使用head standard命令,我们可以轻松地将其删除:
# Each archive end with the 280-byte trailer.
# To catenate both archives, just remove the trailer
# at the end of the first part:
$ head -c-280 part1.cpio | cat - part2.cpio > cat.cpio
$ cpio -it < cat.cpio
felis.txt
felidae.txt
cat.jpg
239 blocks
C.必需的猫命令选项
在使用各种二进制文件格式之后,让我们通过研究专门为处理这些文件而定制的几个选项来回到普通的旧文本文件。 虽然不是POSIX标准的一部分,但这些选项可以在BSD和GNU cat实现中移植。 请注意我不会假装在这里详尽无遗,因此请检查该人以查看系统中cat支持的完整选项列表!
-n:数字行
使用n选项,cat命令将为每个输出行添加其行号前缀:
cat -n felidae.txt
1
2 Felidae \Felidae\ n.
3 a natural family of lithe-bodied round-headed fissiped
4 mammals, including the cats; wildcats; lions; leopards;
5 cheetahs; and saber-toothed tigers.
6
7 Syn: family {Felidae}.
8 [WordNet 1.5]
9
-n选项编号输出行。 这意味着从一个输入文件切换到下一个输入文件时,计数器不会被重置,如果您自己尝试以下命令,您将看到它:
cat -n feli*.txt
-s:抑制重复的空输出行
使用-s选项,cat命令将仅折叠多个连续的空行:
cat -n felis.txt felidae.txt | sed -n 8,13p
8 lynx ({Felis lynx}) is also called {Lynx lynx}.
9 [1913 Webster +PJC]
10
11
12 Felidae \Felidae\ n.
13 a natural family of lithe-bodied round-headed fissiped
linuxidc@linuxidc:~$ cat -ns felis.txt felidae.txt | sed -n 8,13p
8 lynx ({Felis lynx}) is also called {Lynx lynx}.
9 [1913 Webster +PJC]
10
11 Felidae \Felidae\ n.
12 a natural family of lithe-bodied round-headed fissiped
13 mammals, including the cats; wildcats; lions; leopards;
在上面的示例中,您可以看到,在默认输出中,第10行和第11行是空的。 添加-s选项时,第二个空行被丢弃。
-b:仅编号非空行
与前面两个选项有些相关,-b选项会对行进行编号,但忽略空行:
$ cat -b felidae.txt | cat -n
1
2 1 Felidae \Felidae\ n.
3 2 a natural family of lithe-bodied round-headed fissiped
4 3 mammals, including the cats; wildcats; lions; leopards;
5 4 cheetahs; and saber-toothed tigers.
6 5
7 6 Syn: family {Felidae}.
8 7 [WordNet 1.5]
9
上面的示例使用cat命令的两个实例,其中包含管道中的不同选项。内部编号来自第一个cat命令使用的-b选项。外部编号来自第二只猫使用的-n选项。