Hi All, I really need your help. I am a begginner in shell script and I believe this is a very simple issue.
I have in my directory, n-files, like 1.dhm, 2.dhm, 3.dhm.
These files have 1 column with 1 value per line, like:
1.dhm
------
10
20
30
40
50
2.dhm
------
30
50
20
50
80
What I need here, is to make a result file, adding each per file, in this case:
result.txt
---------
40
70
50
90
130
Can someone help me?
Thanks!!
nawk '
{
arr[FNR]+=$1
fnr=FNR
}
END {
for(i=1; i<=fnr; i++)
print arr
}
' *.dhm > result.txt
paste -d+ *.dhm | bc > result.txt
Soham
4
Good and cute solution. But I think we have to verify that each file has same number of records (lines) and all lines are numbers only.
Soham