Tool to copy a file from a given offset "x" (beginning) to a specified offset "y" (end)

Is there any tool for copying a file from a given start offset to a given (final) offset. I also want to confirm that the tool has the correct copies of the specified bytes by running md5sum. Something like that

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 

I know that md5sum does not have the -s and -e options, but I would like to confirm with some tool, given the source file and destination file. thanks in advance

+6
source share
1 answer

For 1) you can use dd :

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

For 2) I am not sure as much as possible with standard tools.

[edit]

Yeah, I found a way:

For 2)

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

And for 3)

 md5sum /path/to/destination/file 
+11
source

Source: https://habr.com/ru/post/922372/


All Articles