title: How to grab an arbitrary chunk from a file on Unix/Linux
body: <p>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.</p>
  <p>I have tried using the <code>dd</code> utility, but this seems to read and discard the data up to the offset, rather than just seeking (I guess because <code>dd</code> is for copying/converting blocks of data). This makes it quite slow (and slower the higher the offset). This is the command I tried:</p>
  <pre><code>dd if=inputfile ibs=1 skip=$offset count=$datalength of=outputfile
  </code></pre>
  <p>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.</p>
  <p>Is there a utility that supports something like this?</p>