The UNIX and Linux Forums  


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-27-2007
baghera baghera is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 23
I really appreciate the help.

I like the xargs thing. Is it then possible to add each element in a column and divide it by the numbers of elements in the column.

I've used this command:

awk '{ sum+=$1/2 }{ sum1+=$2/2} END { print sum sum1 }'

But $1/2 where the 2 should be a variable (the number of elements in the column).

Also ranj@chn I didn't get your script to work, I must be doing something wrong. I just copied what you wrote and tried to run it with:

awk -v var=2 -f reader2.awk testfile.txt

But I only get errors.

And I also tried to run ahmedwaseem2000's program but I didn't get that to work either. I really sorry but I'm a real "noob" at this. But the help you are giving me are invaluable.