Artificial intelligent assistant

add Value in file with value of output generated with script I have a txt/log file which has data- `cat sample.log/(.txt)` 500,3,2 there is script running which overwrite the value in sample.log. Instead of overwrite/or generating a new line I want the data to be get sum up with its respective row. Example: Sample.log -500,3,1 Script out- 600,4,3 Final output that needs to be stored in `sample.log` 1100,7,4 Every time the script run it keeps on adding the respective value. Please help me to get this output.

This is a way to do it using GNU awk where the script is called `script.sh` and the existing total file is called `/tmp/sample.log`:


script.sh|\
cat /tmp/sample.log -|\
awk -F, '{for (f=1;f<=NF;f++) TOT[f]+=$f} END {for (f=1;f/tmp/sample1.log
mv -f /tmp/sample1.log /tmp/sample.log


The output from `script.sh` is combined (put as a line under) the existing `sample.log` and these two lines are then summed in `awk` and the result used to replace `sample.log`

This will work with any number of fields (don't have to be consistent). The delimiter is set to be a comma but this could easily be changed.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 7834968b80c900bf3c2743d01316b30d