Copy byte blocks from one file into another file, with a specified offset and length using the free sfk partcopy command for the Windows, Mac OS X and Linux command line.

sfk partcopy infile offset length outfile [offset2] [-yes]
sfk partcopy infile -allfrom startoffset outfile ...
sfk partcopy infile -fromto startoffset endoffset outfile ...

reads a block of bytes from infile at specified offset,
writing them into another file. if offset2 is specified,
outfile is not created, but the bytes are used to overwrite
other bytes within the output file.

by default, the command simulates, checking file lengths
but not copying any data. add -yes to really copy contents.

negative offsets can be used, to specify positions
relative to the file end instead of file start.

if output offset2 + length is larger than output file size,
the output file is extended. use -noext to avoid this.

length syntax:
    100000   ,  100k        = 100000 bytes
    2000000k , 2000m , 2g   = 2 giga-bytes

options
   -quiet    do not print number of copied bytes.
   -verbose  tell how offsets and lengths are calculated.
             type directly after "partcopy" for all infos.
   -fromto   use this if you don't want to specify offset
             and length for the input, but a start and end
             offset. end offset is exclusive, i.e. length
             is end minus start.
   -fromtoinc  same as -fromto but including end offset,
             so copy length is (end - start) + 1
   -allfrom  copy all from start offset, until end of file.
   -noext    do not allow an extension of the output file,
             stop with error if writing beyond output end.
   -append   if given after output filename, data is added
             to the end of the output file.

see also
   sfk setbytes  write a byte sequence into a file
   sfk hexdump   show binary file contents as hexdump
   sfk hexfind   search data in binary files
   sfk hextobin  convert hexdump to binary

web reference
   http://stahlworks.com/sfk-partcopy

examples
   sfk partcopy first.dat 10000 50 second.dat 500000
      copies 50 bytes from first.dat at offset 10000 into
      second.dat (which should exist) at offset 500000

   sfk partcopy first.dat -fromto 0x2710 0x2950 second.dat
      input start and end offset in hexadecimal numbers,
      output file is created (no output offset given).

   sfk partcopy in.txt -allfrom 1000 out.txt -append
      take from in.txt all data from offset 1000 until end
      and append that to out.txt.

   sfk partcopy in.dat -fromto -1000 -900 out.dat -500
      take from in.dat all bytes from end minus 1000
      until end minus 900, i.e. a 100 bytes block, and
      write this into output at end minus 500 bytes.
      (type -verbose after partcopy for details.)