In Ubuntu desktop 20.04, I have 20 directories, each containing a text file with the same name, "weights". These text files contain ~20-30 numbers separated with a space. In each of the 20 directories, there is also a text file named "coefficient", which contains a single number.
I want to execute a shell command that goes into each directory, sums together all the numbers in the "weights" text file, and multiplies that sum by the number in the "coefficient" text file. If there was some way for this to be put into a csv that would be ideal, but even if it just prints to the terminal that would be okay too!