2012-08-08 13 views
6

与えられた開始オフセットから指定(終了)オフセットまでファイルをコピーするツールはありますか?また、md5sumを実行して、指定されたバイトを正しくコピーしていることを確認したい。私はmd5sum値を知っているこの指定された 'x'(開始)オフセットから指定された 'y'(終了)オフセットまでファイルをコピーするツール

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 

のようないくつかのものは、-sと-eのオプションはありませんが、私は、ソースファイルと先ファイルを指定したいくつかのツールで確認したいと思います。 1を事前に感謝

答えて

11

)あなたはddを使用することができます:2の場合

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

を)私はそれが標準的なツールで達成できるかどう本当にわかりません。

[編集]

なるほど、方法を見つけた:2の場合

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

そして3用)

md5sum /path/to/destination/file 
+0

恐ろしい、それは完璧に動作します。もう一度感謝:) – Viswesn

+0

乾杯:)あなたは大歓迎です。 – favoretti

関連する問題