title: Extract value of column from a line (variable)
body: <p>Okay, so I have a variable ($line) that is defined in the bash/shell script as </p>
  
  <pre><code>$line = "abc:123:def:345" 
  </code></pre>
  
  <p>need to get this column2 = "123" </p>
  
  <p>How do I extract the value of the 2nd column i.e. "123" and name it as a different variable which can be summed later on? I know you have to separate it based on the delimiter ':' but I don't know how to transfer to different variable whilst taking input from $line variable. I only ask this because for some weird reason <strong>my code reads the first line of text file BUT doesn't perform the awk on just the first line only</strong> so hence the sum is wrong. </p>
  
  <pre><code>FILE=$1
  while read line
  do
   awk -F: '{summation += $3;}END{print summation;}'
  done &lt; $FILE
  </code></pre>
  
  <p>-code via shell script</p>
  
  <p>Thanks.</p>