title: Using AWK to find the smallest and largest number in a column?
body: <p>If I have a file with few column and I want to use an AWK command to show the largest and the lowest number in a particular column!</p>
  
  <p>example:</p>
  
  <pre><code>a  212
  b  323
  c  23
  d  45
  e  54
  f  102
  </code></pre>
  
  <p>I want my command to show that the lowest number is 23 
  and another command to say the highest number is 323</p>
  
  <p>I have no idea why the answers are not working! I put a more realistic example of my file( maybe I should mention that is tab determined)</p>
  
  <pre><code>##FORMAT=&lt;ID=DP,Number=1,Type=Integer,Description="# high-quality bases"&gt;
  ##FORMAT=&lt;ID=SP,Number=1,Type=Integer,Description="Phred-scaled strand bias P-value"&gt;
  ##FORMAT=&lt;ID=PL,Number=-1,Type=Integer,Description="List of Phred-scaled genotype likelihoods, number of values is (#ALT+1)*(#ALT+2)/2"&gt;
  #CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT  rmdup_wl_25248.bam
  Chr10   247     .       T       C       7.8     .       DP=37;AF1=0.5;CI95=0.5,0.5;DP4=7,1,19,0;MQ=15;FQ=6.38;PV4=0.3,1,0.038,1 GT:PL:GQ        0/1:37,0,34:36
  Chr10   447     .       A       C       75      .       DP=30;AF1=1;CI95=1,1;DP4=0,0,22,5;MQ=14;FQ=-108 GT:PL:GQ        1/1:108,81,0:99
  Chr10   449     .       G       C       35.2    .       DP=33;AF1=1;CI95=0.5,1;DP4=3,2,20,3;MQ=14;FQ=-44;PV4=0.21,1.7e-06,1,0.34        GT:PL:GQ        1/1:68,17,0:31
  Chr10   517     .       G       A       222     .       DP=197;AF1=1;CI95=1,1;DP4=0,0,128,62;MQ=24;FQ=-282      GT:PL:GQ        1/1:255,255,0:99
  Chr10   761     .       G       A       27      .       DP=185;AF1=0.5;CI95=0.5,0.5;DP4=24,71,8,54;MQ=20;FQ=30;PV4=0.07,8.4e-50,1,1     GT:PL:GQ        0/1:57,0,149:60
  Chr10   1829    .       A       G       3.01    .       DP=74;AF1=0.4998;CI95=0.5,0.5;DP4=18,0,54,0;MQ=19;FQ=4.68;PV4=1,9.1e-12,0.003,1 GT:PL:GQ        0/1:30,0,45:28
  </code></pre>
  
  <p>I should say that I have already add excluding line that start with # so this is the command that I use:</p>
  
  <pre><code>awk '$1 !~/#/' | awk -F'\t' 'BEGIN{first=1;} {if (first) { max = min = $6; first = 0; next;} if (max &lt; $6) max=$6; if (min &gt; $6) min=$6; } END { print min, max }' wl_25210_filtered.vcf
  
  awk '$1 !~/#/' | awk -F'\t' 'BEGIN{getline;min=max=$6} NF{ max=(max&gt;$6)?max:$6 min=(min&gt;$6)?$6:min} END{print min,max}' wl_25210_filtered.vcf
  </code></pre>
  
  <p>and </p>
  
  <pre><code>awk '$1 !~/#/' | awk -F'\t' '
  NR==2{min=max=$6;next}
  NR&gt;2 &amp;&amp; NF{
      max=(max&gt;$6)?max:$6
      min=(min&gt;$6)?$6:min
  }
  END{print min,max}' wl_25210_filtered.vcf
  </code></pre>