I have two files, tab separated, where I want to compare line by line the values of column 1 of file1 with column 1 of file2 and so forth until n columns.
The comparisons are to count the differences.
Values in columns can be either 0, 1 or 2, for example:
File1:
col1 col2 col3 col4
1 1 1 2
1 1 1 2
2 1 2 2
2 1 2 2
File2:
col1 col2 col3 col4
1 1 1 1
1 1 0 1
0 1 0 1
1 0 1 0
Results
2 1 3 4
So, col1 of file1 and file2 with 2 differences, col2 off file1 and file2 with 1 difference and so forth... I have seen many similar questions in AWK but the majority of them is to compare columns and append a column from either files if matches or not, but not count differences.
I believe the comparison of not match from two columns would start with something like this, but from there I am totally lost...
awk 'NR==FNR { a[$1]!=$1; next}
Thanks
col1 of file1 and file2 with 2 differences
: Are you sure about this? It is same in both files i.e.1 1 2 2
values? – anubhava