average each column in a file

Hi, I tried to do this in excel but there is a limit to how many rows it can handle.

All I need to do is average each column in a file and get the final value.

My file looks something like this (obviously a lot larger):

Joe HHR + 1 2 3 4 5 6 7 8
Jor HHR - 1 2 3 4 5 6 7 8 

the output would be (average values only):

1 2 3 4 5 6 7 8 

Thanks

awk '{ M=NF; for(N=4; N<=NF; N++) T[N]+=$N }
END {
        printf("%f", T[4]/NR);
        for(N=5; N<=M; N++) printf("\t%f", T[N]/NR);
        printf("\n");
 }' filename
1 Like