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 -->
  #4 (permalink)  
Old 08-30-2007
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by ranj@chn View Post
Code:
awk -f temp.awk tempfile
where temp.awk is
Code:
{ for(i=1;i<=NF;i++) { sum[i]+=$i } }
END { for (i in sum) {printf("%f\t", sum[i]/NR) } }
ranj,
when iterating through an array 'sum' with the index of 'i', the order of the iteration is indeterminant, i.e. don't assume that 'i' will go from '1' to 'NF'.