Compare two files with different column entries..:-(

Dear All,
I would appreciate any help..At the moment, my work is stuck cos of my inability to resolve this issue.
Which is following:
I have two files with the arrngment like this
file-1

190645 12 3596022
190645 12 3764915
190645 16 3803981
190645 12 3854102
190645 12 4324593
190645 13 4894025

And second file-2 (which I know has less entries then file-1)

190645 12 3854102
190645 12 3596022
190645 12 3764915
190645 16 3803981
190645 12 4324593

As you can see, the content in both files are SAME except the RED one.
But in this case, the DIFF command wont work..and I am puzzled. As the original such file has thousands of entries..:frowning:

Plesae let me know how to get the REd marked files from the file-1 or the differenence of two files based on the matching of three column together.

Please help..:frowning:

Thanks in Advance,
emily

sort file1.txt > file1
sort file2.txt > file2
comm -23 file1 file2

Hi doganaym,
Thanks for the quick reply..the first two commands seem to be working...and the files are sorted..
But I am afraid even after neither third command as you provided worked nor the 'diff' command. :frowning:

---------- Post updated at 04:17 PM ---------- Previous update was at 04:12 PM ----------

Hi again,
command is working all fine for the example file that I provided here.
Not sure, why its not working on my huge list of files..

Checking ! Thanks again for your help,
emily

---------- Post updated at 04:27 PM ---------- Previous update was at 04:17 PM ----------

I tried that as well, no use..
Somehow the file1 has 1636 entries and the second file has 1538 entries..differnce is of around ~100.
But the comm, diff, and your new command all are giving the final difference file with entries more than 2000..:frowning: thats annoying..not sure wats happening..

emily..

Sorry,to be precise, the difference is comign at the moment is 10556 entries..:frowning: :frowning:

awk 'FNR==NR{a[$0]++;next} !($0 in a)' file2 file1
190645 13 4894025

Hi,
Thakns for the reply..
Unfortunately, on the main files, it is giving 10663 entries..though the differencce is around 100 in both files.
I did following, jst to mention:

sort file_1 > file1
sort file_2 > file2
awk 'FNR==NR{a[$0]++;next} !($0 in a)' file2 file1 > differene.txt &

And the difference.txt has 10663 entries.

Even if all lines are different (which i know defnitely not the case is), then also it should be 1064 + 1058 = ~2k...

emily

Check file_2_diff file which will be having entries which is not present in file_1. and file_1_diff file which will be having entries which is not present in file_2.

awk 'NR==FNR{A[$0]=$0;next}{if(A[$0]){delete A[$0]}else{print > "file_2_diff"}}
    END{for(i in A){if(A){print A > "file_1_diff"}}}' file1 file2

Hi Pamu,
Thanks for replying.
Unfortunately, It did not work either.
Here, I am attaching my actual files

Here is what I get form your files. Correct?

Lists what only found in file2.txt

awk 'FNR==NR{a[$0]++;next} !($0 in a)'  events.txt file2.txt
190703 35 38948630
190703 19 18075966
190703 165 192734766
190705 54 52441489
190705 103 105369927
190705 235 297231449
190705 210 262031535
190705 27 23277619
190702 150 147424320
190705 359 464498887
190702 91 70154480

Lists what only found in evnets.txt

awk 'FNR==NR{a[$0]++;next} !($0 in a)'  file2.txt events.txt
190645 93 67998599
190646 31 20393191
190646 41 28121749
190659 44 18778029
190659 70 35602976
190659 100 45177234
190659 116 50105727
190659 135 55519135
190659 155 61455904
190659 158 62258481
190659 165 64359997
190659 165 64541772
190679 18 9945283
190688 98 22237449
190688 102 24166877
190688 132 39518870
190688 158 52186902
190688 163 54692415
190688 179 62350245
190688 214 78331828
190688 220 81350318
190702 55 22168214
190702 61 32250475
190702 62 33141901
190702 62 34283887
190702 80 55166911
190702 83 60139876
190702 88 66284373
190702 109 94092288
190702 113 99578354
190702 116 103833770
190702 120 109216333
190702 121 109636060
190702 127 117303322
190702 127 118114434
190702 129 119939753
190702 129 120538210
190702 129 121068623
190702 132 124845294
190702 148 145282268
190702 167 169525472
190702 168 169837559
190703 19 18446279
190703 38 41667716
190703 69 80030416
190703 70 81265783
190703 72 83574738
190703 76 88531085
190703 79 91710900
190703 87 101227094
190703 93 107433687
190703 105 121573703
190703 119 138358156
190703 125 145074103
190703 129 150227682
190703 129 150348329
190703 129 150401907
190703 140 163333372
190703 157 182616920
190703 157 183221216
190703 163 189430783
190703 168 195733886
190703 178 206945907
190703 189 219906423
190703 204 236061943
190703 207 240060204
190703 228 263189350
190703 240 275999531
190703 242 278007689
190703 248 285140680
190703 252 288824126
190705 7 1070021
190705 7 1354911
190705 9 4046413
190705 36 33075514
190705 53 51129931
190705 53 51417312
190705 60 58561783
190705 62 60931288
190705 84 82367697
190705 97 96198696
190705 112 119790742
190705 138 158349052
190705 146 169237303
190705 147 171353449
190705 150 175908381
190705 151 177510327
190705 151 177596335
190705 169 203496730
190705 186 227909186
190705 189 232189484
190705 194 238715591
190705 204 252875117
190705 205 254958833
190705 211 262738661
190705 212 264681374
190705 214 267682215
190705 219 274468283
190705 219 275378999
190705 221 277044071
190705 243 308015875
190705 250 317425823
190705 263 335523611
190705 275 352893172
190705 277 354965080
190705 280 359482523
190705 291 373778585
190705 306 393695319
190705 314 404263304
190705 317 408334646
190705 326 421120406
190705 331 427827184
190705 338 436473770
190705 349 450393264
190705 358 462976451
190705 381 492621773

how about this ?

 
fgrep -v -f events.txt file2.txt

@emily
What os do you have and what version of awk is running

awk --version

Did this solve your need ?

sort file1 file2 | uniq -u

Not sure if this is a good solution, it does not show what file that have unique values, just a mix of unique from both files.