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 -->
  #5 (permalink)  
Old 08-28-2007
baghera baghera is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 23
Thanks Jean-Pierre, now I don't get any errors. But the output is wierd.

If I have the list:

1
2
1
2

This would produce:
1 2
1 2

So the output should be 1 and 2 (1+1/2 and 2+2/2 ), like so:
1
2

But instead I get

2
2

Something is wrong with the way I'm going about this problem.

echo "$data" | awk -v i=$1 '{sum+=$i} END {print sum/NR}'

Is there something wrong with using NR here? But putting a number there doesn't seem to help. I tried with 2 instead of NR but (same list as above) but still I get:

2
2

Is there a problem with the division I'm making?

Edit: I just echoed data and the output comes in one line 1 2 1 2 so probably is has something to do with my problem.

Last edited by baghera; 08-28-2007 at 02:50 PM..