I used comm
to compare two sorted files.
Each line in these files are positive integer numbers.
But the results show
comm: file 1 is not in sorted order
comm: file 2 is not in sorted order
How come the error even if these two files are sorted?
Best Answer
comm
requires lexicographic sort (plainsort
), not numeric sort (sort -n
). For example, it wants the following order:Not the following order:
Correct this and the problem should go away. For more esoteric cases where
comm
's locale may be different than thesort
locale, you may want to runsort
andcomm
withLC_COLLATE=C
in their environment to use native byte ordering.