title: Print min and max with awk
body: <p>Why wont this awk script work, where I want to print the min and max of an input by just reading the data once.  I would also like to initialize the min and max variable with the first value of the data.</p>
  <p>Say I have a file</p>
  <pre><code>a 14
  a 34
  a 234
  a 2345
  a 1
  a 24
  </code></pre>
  <p>I am using awk to print the min and max with:</p>
  <pre><code>cat test.txt | awk 'BEGIN {min=$2; max=$2} {if ($2 &lt; min) {min=$2}; if ($2 &gt; max) {max=$2} } END {print &quot;min: &quot; min &quot;max: &quot; max}'
  </code></pre>
  <p>But I am getting a result of:</p>
  <pre><code>min: max: 2345
  </code></pre>
  <p>I dont understand why min is set to blank?</p>