I have 2 files rec1.txt and rec2.txt.
[gpadmin@subh ~]$cat ret1.txt
emcas_fin_bi=324
emcas_fin_drr=3294
emcas_fin_exp=887
emcas_fin_optics=0
emcas_gbo_gs=3077
and
[gpadmin@subh ~]$ cat ret2.txt
emcas_fin_bi=333
emcas_fin_drr=5528
emcas_fin_exp=1134
emcas_fin_optics=0
emcas_fin_revpro=0
emcas_gbo_gs=3897
I am providing for compare as :-
[gpadmin@subh ~]$ diff -y ret1.txt ret2.txt
emcas_fin_bi=324 | emcas_fin_bi=333
emcas_fin_drr=3294 | emcas_fin_drr=5528
emcas_fin_exp=887 | emcas_fin_exp=1134
emcas_fin_optics=0 emcas_fin_optics=0
emcas_gbo_gs=3077 | emcas_fin_revpro=0
> emcas_gbo_gs=3897
I see this is wrong output from above output since emcas_gbo_gs is common but showing as new word:-
emcas_gbo_gs=3077 | emcas_fin_revpro=0
> emcas_gbo_gs=3897
Desired Output :-
emcas_gbo_gs=3077 | emcas_gbo_gs=3897
> emcas_fin_revpro=0
diff
does a line-by-line comparison and-y
puts the output in two columns which is exactly what you have.emcas_gbo_gs=3897
appears on the sixth line in the second file whereas your first file doesn't have a sixth line. – Nasir Riley Aug 26 '18 at 23:20diff
doesn't work in the way that would be required for giving you that output. – Nasir Riley Aug 26 '18 at 23:27diff
compares the files line-by-line so it will never give you that output with those two files. In fact, it would be wrong if it did do that because it would be comparing two different lines. I don't see any reason why you can't work with the output it's giving you as it's telling you exactly where the two files are different. Your desired output wouldn't make any sense. – Nasir Riley Aug 26 '18 at 23:46emcas_gbo_gs
and notemcas_fin_bi
? Both options have changed. Don't you want to see all optons that differ between files? – Kamil Maciorowski Aug 27 '18 at 05:35