8

是否有任何工具可以将文件从给定的起始偏移量复制到给定的(结束)偏移量。我还想通过运行 md5sum 来确认该工具是否正确复制了指定的字节。像这样的东西

   1) Copy source file starting from 100 byte till 250th byte
        $cp /path/to/source/file /path/to/dest/file -s 100 -e 250

   2) Create md5sum of the source file starting from 100byte till 250th byte
        $md5sum /path/of/src/file -s 100 -e 250
         xxxxxx-xxxxx-xxxxx-xxxx-xx

   3) Confirm that destination file created from step 1 is right by comparing the md5sum generated from step 2.
        $md5sum /path/of/dest/file
         xxxxxx-xxxxx-xxxxx-xxxx-xx

我知道 md5sum 没有 -s 和 -e 的选项,但我想通过给定源文件和目标文件的一些工具来确认。提前致谢

4

1 回答 1

16

对于 1) 你可以使用dd

# dd if=/path/to/source/file of=/path/to/destination/file bs=1 skip=100 count=250

对于 2) 我不确定这是否可以通过标准工具实现。

[编辑]

啊哈,找到了一个方法:

对于 2)

# dd if=/path/to/source/file bs=1 skip=100 count=250 | md5sum

对于 3)

md5sum /path/to/destination/file
于 2012-08-08T15:20:45.970 回答