I have 3 files and each contain m*n matrix.
m = number of rows (horizontal lines)
n = number of columns (entries in a particular line)
What I wish to find is the sum of the 2nd number in the last row.
Ex
file1.dat
2 5 8 8
4 6 7 8
3 8 3 7
file2.dat
3 4 1 4
8 4 0 3
4 7 3 7
file3.dat
9 6 3 5
8 4 8 4
7 5 6 8
The desired result is 8+7+5 ie., 20
What I tried is;
i=1
sum1=0
while [ $i -lt 4 ]
do
tail -1 file$i.dat | awk '{print $2+"$sum1"}'
let i=$i+1
done
echo $sum1
But this is not working.
Please help....
Thanks in advance
__________________