title: bash sort numerical osx
body: <p>This is sort of a re-post/development of a question:</p>
  
  <p>I've tried to use the command</p>
  
  <pre><code>  tr '\r' '\n' &lt; myfile.txt | sort &gt; myfile_num.txt
  </code></pre>
  
  <p>to a file containing about 900 lines of data, that I want to sort numerically. It seems like others are able to get the right output file with all lines included (as below) but I'm not. Instead I get "tr: illegal byte sequence"</p>
  
  <p>myfile.txt</p>
  
  <pre><code>    0251  abcd 1234,24 bcde
      2240  efgh 2345,98 ikgpppm
      0001  lkjsi 879,09 ikol
  </code></pre>
  
  <p>I'd like to get:</p>
  
  <p>myfile_num.txt</p>
  
  <pre><code>0001  lkjsi 879,09 ikol 
  0251  abcd 1234,24 bcde
  2240  efgh 2345,98 ikgpppm
  </code></pre>
  
  <p>Am I doing something wrong with the rest of the file? Am I saving it wrongly? </p>
  
  <p>Thanks :)</p>