The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 09-01-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 596
Am not sure whether I get the issue properly, but here is the code: I just assume that you will be taking the first and third fields from first line.

Code:
awk 'BEGIN {sum=0; } {if (NR==1){ var1=$1; var3=$3;}  sum += $2; } END { print var1" "sum" "var3 }' filename