I am attempting to get the differences of both files, line number and content either in another file or stdout. I have attempted the below, yet, not able to get the exact desired output. Please see below.
File contents:
File1:
Col1,Col2,Col3
Text1,text1,text1
Text2,text2,Rubbish
File2:
Col1,Col2,Col3
Text1,text1,text1
Text2,text2,text2
Text3,text3,text3
I have tried the following code which does not provide the exact desired output as it only shows the difference in the first file and not the extra line in file2.
sort file1 file2 | uniq | awk 'FNR==NR{ a[$1]; next } !($1 in a) {print FNR": "$0}' file2 file1
Output
3: Text2,text2,Rubbish
Desired Output
3: Text2,text2,Rubbish (File1)
3: Text2,text2,text2 (File2)
4: Text3,text3,text3 (File2)
I DONOT wish to use diff/sdiff/comm because of the outputs, as I cannot add line number and organise the data side by side for ease of reading. Normal files would be in excess of 1000 lines so diff/sdiff utilities become more difficult to read.