title: How to format a column with awk and printf when values are either numeric or string
body: <p>I have the following file, where I want to left-pad with zeros when the value is numeric, but leave it as it is when value is a string:</p>
  
  <pre><code>cat test.txt 
  2032
  12
  XXXXX
  507
  334
  </code></pre>
  
  <p>This works only for numeric values, the string being ignored:</p>
  
  <pre><code>awk '{printf "%05d\n",$1}' test.txt 
  02032
  00012
  00000
  00507
  00334
  </code></pre>
  
  <p>I can get it with a condition, but is there a simpler way ?</p>
  
  <pre><code>awk '{if ($1 ~ /^[0-9]+$/) printf "%05d\n",$1; else printf "%s\n",$1}' test.txt 
  02032
  00012
  XXXXX
  00507
  00334
  </code></pre>