title: How to remove leading and trailing whitespaces?
body: <p>I'm using <code>awk '{gsub(/^[ \t]+|[ \t]+$/,""); print;}' in.txt &gt; out.txt</code> to remove both leading and trailing whitespaces.</p>
  
  <p>The problem is the output file actually has trailing whitespaces! All lines are of the same length - they are right padded with spaces.</p>
  
  <p>What am I missing?</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>The problem is probably due to the the fact that the trailing spaces are nor "normal" spaces but \x20 characters (DC4).</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>I used <code>gsub (/'[[:cntrl:]]|[[:space:]]|\x20/,"")</code> an it  worked.
  Two strange things:</p>
  
  <ol>
  <li><p>Why isn't \x20 considered a control character?</p></li>
  <li><p>Using <code>'[[:cntrl:][:space:]\x20</code> does NOT work. Why?</p></li>
  </ol>