title: How to substitute/replace bytes in binary file with shell
body: <p>is it possible to substitute bytes from a binary file <strong>myfile</strong> from one specific position to another with <strong>dd</strong> in a loop or is it more comfortable using another command?</p>
  
  <p>The idea is to replace a block <strong>B</strong> at position <strong>position2</strong> with block <strong>A</strong> at <strong>position1</strong> in a loop.</p>
  
  <p><strong>PSEUDO CODE</strong></p>
  
  <pre><code>  @ l = 0
  
    while (l &lt;= bytelength of myfile)
        copy myfile (from position1 to A+position1)  myfile from (position2 to B+position2)
        @ position1 = position1+steplength
        @ position2 = position2+steplength
        @ l = l+steplength
  
    end
  </code></pre>