title: Hot to match a number in AWK
body: <p>I want to let awk print all the numbers from the input, so I wrote  </p>
  
  <pre><code>echo 2 1a 12121 -1212 abc | 
  awk ' { for (i=1;i&lt;=NF;i++) if ($i ~ /[-.0-9]*/) print $i; } '
  </code></pre>
  
  <p>What I want to say is 'strings consists of '0-9' '.' '-', but in the output it prints every fields out, what did I do wrong?</p>