I'm trying to copy a chunk from one binary file into a new file. I have the byte offset and length of the chunk I want to grab.
I have tried using the dd
utility, but this seems to read and discard the data up to the offset, rather than just seeking (I guess because dd is for copying/converting blocks of data). This makes it quite slow (and slower the higher the offset. This is the command I tried:
dd if=inputfile ibs=1 skip=$offset count=$datalength of=outputfile
I guess I could write a small perl/python/whatever script to open the file, seek to the offset, then read and write the required amount of data in chunks.
Is there a utility that supports something like this?