|
From: | Ali Khanafer |
Subject: | bug#19533: comm does not detect common lines -- Mac OS X 10.9.5 |
Date: | Thu, 8 Jan 2015 11:56:51 -0500 |
Eric Blake wrote:
> Ali Khanafer wrote:
> > I tried comm on test1.txt and test2.txt. The output I got is in
> > comm-test.txt. Comm found 11 common lines and missed 6 other lines.
> >
> > Could you please explain why this is happening?
>
> Using a newer version of coreutils would tell you why:
> ...
> Proper use of comm requires that you pre-sort both input files. As
> such, this is not a bug in comm, so I'm closing this bug. However, feel
> free to add further comments or questions.
If you are using bash then a bash specific feature is useful. You can
sort them on the fly.
comm <(sort test1) <(sort test2)
Or perhaps forcing a sort locale.
env LC_ALL=C comm <(sort test1) <(sort test2)
I included LC_ALL=C to force a specific sort order which may or may
not be appropriate for all of your use cases.
Bob
[Prev in Thread] | Current Thread | [Next in Thread] |