Input File:

1 2 3 4 5 

6 4 2 1 2

3 6 7 8 9 

and so on..

Desired Output:




I have many files and each file with different numbers of column but the no. of rows is the same 25000. I want to have the same number of rows but only one column.

Any suggestion by using awk?


You can use this:

awk '{for(i=1;i<=NF;i++) t+=$i; print (t/(i-1)); t=0}' filename

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.