title: Sh, awk: how to convert integers, visible in the shell as a string to 16-bit low-/big- endian binary integers?
body: <p>I have a bash sequence, </p>
  
  <pre><code>grep "integer =" $1 | awk -F= '{printf("%d\n",int($2*327))}'
  </code></pre>
  
  <p>which filters something producing smth like:</p>
  
  <pre><code>6768
  6572
  6638
  8403
  8436
  8436
  8305
  8502
  </code></pre>
  
  <p>I need however all these numbers to be placed in a binary file as 16-bit low-endian words (or big-endian if specified). Is there any awk-, bash- way to do it?</p>
  
  <p>Ideally, it could look like:</p>
  
  <p><code>grep "integer =" $1 | awk -F='{TO16BIT_LENDIAN(printf("%d\n",int($2*327)))}' &gt;&gt; out.bin</code></p>