What I need to do is write a shell program called avgs that would read lines from the file with data, where the title line could be at any line within the data.
I must keep a total and count for each of the last 2 columns and must not include data from the first line in the totals and counts.
This is the file with the data:
92876035 SMITZ S 15 26 95908659 CHIANG R 10 29 SID LNAME I T1/20 T2/30 92735481 BRUCE. R 16 28 93276645 YU C 17 27 91234987 MYRTH R 15 16
The shell program will write to stdout the line: "The averages are 17 and 24"
This is what I tried but it doesn't work
count_ppl=0 total=0 while read ?? ?! do total=$((sum+b)) count_ppl=$((count_ppl+1)) done < filename avg=$(echo "scale=2;$total/$count_ppl" | bc) echo "The averages are = $avg"
The "??" and "?!" are there beside the "while read" because I do not know what to put there.
I guess this probably computes one averages for one column, but how would I get the data from the columns and compute two averages.
(this is bash btw).