Extracting combined differences based on a single column

Dear All,
I have two sets of files. File 1 can be any number between 1 and 20 followed by a frequency of that number in a give documents... the lines in the file will be dependent to the analysed document. e.g.
file1

1,5
4,1

then I have file two which is basicall same numbers but with frequency of 0
file2

1,0
2,0
3,0
4,0
...
20,0

I want to create a third file which will map the file1 on file2
file3 - outcome

1,5
2,0
3,0
4,1
...
20,0

I have tried

awk -F, 'FNR==NR{X[$1]=$2;next}$1 in X{print $1","X[$1]==$2;next}{print $1","0}' file1 file2

but it does not print what is required and puts 0 for any item from file1
Can you please help?

This looks like you're just combining both files and sorting them.
So if file x.x is one of the files and y.y the other, then,...

cat x.x y.y | sort

Please clarify.

1 Like

Dear Blackrageous, No, I am not combining. I want to fill the gaps in file1 by the data from the file2
my file2 is always the same and has 20 lines while file1 might have any combination. I want to make sure file1 has 20 lines as well and the values that are missing will be extracted from file2