title: Extract lines corresponding to the minimum value in the last column
body: <p>I need help with extracting all the lines from the file that has minimum number in the last column, i.e 7 in in this case.</p>
  
  <p>The sample file is as below:</p>
  
  <p>File-1.txt</p>
  
  <pre><code>VALID_PATH :  [102, 80, 112, 109, 23, 125, 111] 7
  VALID_PATH :  [102, 81, 112, 109, 23, 125, 111] 7
  VALID_PATH :  [102, 112, 37, 109, 23, 125, 111] 7
  VALID_PATH :  [102, 112, 37, 56, 23, 125, 111]  7
  VALID_PATH :  [102, 80, 112, 37, 109, 23, 125, 111] 8
  VALID_PATH :  [102, 80, 112, 37, 56, 23, 125, 111]  8
  VALID_PATH :  [102, 80, 112, 109, 23, 125, 110, 111]    8
  VALID_PATH :  [102, 80, 127, 6, 112, 109, 23, 125, 111] 9
  VALID_PATH :  [102, 80, 127, 88, 112, 109, 23, 125, 111]    9
  VALID_PATH :  [102, 80, 112, 37, 109, 23, 125, 110, 111]    9
  VALID_PATH :  [102, 80, 112, 37, 56, 23, 125, 110, 111] 9
  VALID_PATH :  [102, 80, 127, 6, 112, 37, 109, 23, 125, 111] 10
  VALID_PATH :  [102, 80, 127, 6, 112, 37, 56, 23, 125, 111]  10
  VALID_PATH :  [102, 80, 127, 6, 112, 109, 23, 125, 110, 111]    10
  </code></pre>
  
  <p>Here, I want to extract all the lines that have 7, which is the least value (minimum value) in the last column and save the output into another file File-2.txt by only extracting the values enclosed in [], as shown below.</p>
  
  <p>File-2.txt</p>
  
  <pre><code>102, 80, 112, 109, 23, 125, 111
  102, 81, 112, 109, 23, 125, 111
  102, 112, 37, 109, 23, 125, 111
  102, 112, 37, 56, 23, 125, 111
  </code></pre>
  
  <p>I could use awk to get the least value as "7" from the last column using the code as below:</p>
  
  <pre><code>awk 'BEGIN{getline;min=max=$NF}
  NF{
      max=(max&gt;$NF)?max:$NF
      min=(min&gt;$NF)?$NF:min
  }
  END{print min,max}' File-1.txt
  </code></pre>
  
  <p>and to print only the values in square brackets [] buy using the awk code as below:</p>
  
  <pre><code>awk 'NR &gt; 1 {print $1}' RS='[' FS=']' File-1.txt
  </code></pre>
  
  <p>but, I am stuck in assigning the least value obtained from first awk script, i.e. 7 in this case to extract the corresponding numbers enclosed in [], as shown in File-2.txt.</p>
  
  <p>Any help in resolving this problem will be appreciated.</p>