Say I have some files named file1, file2, file3
, ... that have the following format
file1
blah blah blah
[PATTERN0]
a10
a20
a30
[PATTERN1]
a11
a21
a31
[PATTERN3]
a13
a13
a33
file 2
blah blah blah
[PATTERN0]
b10
b20
b30
[PATTERN1]
b11
b21
b31
[PATTERN3]
b13
b13
b33
What I would like to do is end up with a file that contains the sum of each individual entry for all files after the specific pattern (i.e. PATTERN0). For instance the file should have
a10+b10
a20+b20
a30+b30
So far I can only rrad and print the values using
awk '/PATTERN0/ {for(i=1; i<=3; i++) {getline;print $1}}' file*
Any idea how to do it?
paste
inawk
but I can't make the connection on how to usepaste
first, unless you are referring to something else.paste file* > combined.txt
so that each line of the files get combined in single line separated by a delimiter (tab by default)... then you read that file and use awk.. but seems you have a simple awk alone solution :)paste
! I will try to find a way! Is it possible to post an answer with that?