title: Convert human readable to bytes in bash
body: <p>So I am trying to analyze very large log files in linux and I have seen plenty of solutions for the reverse of this, but the program that records the data doesn't allow for output formatting therefore it only outputs in human readable format (I know, what a pain).  So the question is:  How can I convert human readable to bytes using something like awk:</p>
  
  <p>So converting this:</p>
  
  <pre><code>937
  1.43K
  120.3M
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>937
  1464
  126143693
  </code></pre>
  
  <p>I can afford and I expect some rounding errors.</p>
  
  <p>Thanks in advance.</p>
  
  <p>P.S.  Doesn't have to be awk as long as it can provide in-line conversions.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/8535448/find-a-substring-replace-and-multiply-by-1024">this</a> but the awk command given doesn't appear to work correctly.  It outputs something like 534K"0".</p>
  
  <p>I also found a solution using sed and bc, but because it uses bc it has limited effectiveness meaning it only can use one column at a time and all the data has to be appropriate for bc or else it fails.</p>
  
  <p><code>sed -e 's/K/\*1024/g' -e 's/M/\*1048576/g' -e 's/G/\*1073741824/g' | bc</code></p>