title: BASh - Convert list of hex values to binary file (application)
body: <p>I have a file containing hex representations of code from a small program, and am trying to actually convert it into the program itself.</p>
  
  <p>For example, here is a sample of such text, stored in a file, <code>input.txt</code>:</p>
  
  <pre><code>8d
  00
  a1
  21
  53
  57
  43
  48
  0e
  00
  bb
  </code></pre>
  
  <p>I am using the following BASh snippet to convert the file to a binary file:</p>
  
  <pre><code>rm outfile; while read h; do echo -n ${h}; echo -ne \\x${h} &gt;&gt; outfile; done &lt; input.txt
  </code></pre>
  
  <p>After opening the output file in VIM:</p>
  
  <pre><code>¡!SWCH»
  </code></pre>
  
  <p>And then converting it to hex representation via <code>xxd</code>:</p>
  
  <pre><code>0000000: 8d00 a121 5357 4348 0e00 bb0a            ...!SWCH....
  </code></pre>
  
  <p>This is all good, except for one thing: There is a trailing byte, <strong><code>0a</code></strong>, trailing at the end of my binary output file. This happens for every program file I work with. How is the trailing <code>0a</code> being appending to every output binary file? It's not present in my input file.</p>
  
  <p>Thank you.</p>