I have two CSV files and i have the requirement to calculate the sum of the 8th column from File1 and File2 for every row. The two CSV files have exactly 24 rows each and to simplify the things i have extracted the 8th row of each CSV file using:
awk -F, '{ print $8 }' >> FILE1 awk -F, '{ print $8 }' >> FILE2
Now, i have 2 file data in the following format:
File1
1 2 3 4
File2
2 3 4 5
How can i make the calculations in the way that
File1.Col1 + File2.Col1 = File3.Col1 File1.Col2 + File2.Col2 = File3.Col2 File1.Col3 + File2.Col3 = File3.Col3 . . .
resulting in:
File3
3 5 7 9
and so on using Bash Shell script because rest of my processing is being done in the same.
File1.Row1 + File2.Row1 = File3.Row1
, etc?awk
script; there's no need to extract the 8th columns of your CSV files into temporary files. To read two or more files in parallel you can use awk'sgetline
statement.