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 > UNIX for Advanced & Expert Users
.
google unix.com




Thread: awk help
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-17-2008
mohan705 mohan705 is offline
Registered User
  
 

Join Date: Feb 2007
Posts: 134
awk help

Hi

In my file there are 4 columns having amount fields,but I am getting different amounts using the below one's



awk -F "|" '{a+=$1+$2+$3+$4} END {printf ("%f\n",a)}' file

1123337200682.226562

awk 'BEGIN{FS=OFS="|"} {for(i=1;i<=NF;i++) {a+=$i;n++ }} END {printf ("%f\n",a)}' file

1123337200684.453613



Thanks,
MR