title: AWK Assignment to variable
body: <p>I am looking for assignment of value of variable to another variable in awk.</p>
  
  <p>Below is the example</p>
  
  <pre><code>if (substr($0,1,1) == "4") 
  {
      COUNT_DETAIL_SEG++
      SUM_OF_DETAIL_RCDS=$(COUNT_DETAIL_SEG)
      print "Sum of detail records is" SUM_OF_DETAIL_RCDS
  }
  </code></pre>
  
  <p>Suppose if 1st character of line comes out to be "4" then i want to increment value of <code>COUNT_DETAIL_SEG</code> and assign this value to <code>SUM_OF_DETAIL_RCDS</code> and thereby print it.
  But i am unable to retain this value.
  Can anyone have any idea about this?</p>