答案有点晚,但这个 dd 示例对我有用。
创建示例源文件:
$ dd if=/tmp/somefile of=/tmp/test skip=50 bs=100 count=1
跳过 50 个字节并将其后的 10 个字节复制到 test_skip 文件:
$ dd if=/tmp/test of=/tmp/test_skip skip=50 bs=1 count=10
10+0 records in
10+0 records out
10 bytes (10 B) copied, 8.2091e-05 s, 122 kB/s
或来自标准输入的数据:
cat /tmp/test| dd of=/tmp/stdin bs=1 skip=50 count=1
验证输出:
$ hexdump /tmp/test
0000000 ebf3 e8fd df1b 0aa1 faa3 1fba 1817 1267
0000010 1402 f539 fb69 f263 f319 084b 0b26 1150
0000020 182a f98d 030c e0b0 e47c f13d ef3b 1146
0000030 0b7e 0f72 0e58 f2bd f403 ee95 e529 0567
0000040 f88e 1994 0e83 12e5 11e7 fd4b 032f f4f0
0000050 fc9d 010a 0ab6 06b6 1224 f5cb 01e4 e67a
0000060 ebe0 f1a0
0000064
$ hexdump /tmp/test_skip
0000000 0f72 0e58 f2bd f403 ee95
源文件偏移量 50 为字节:0x0f