When I use ‘join’ to merge two sorted files, the result is unexpected.
here is the example:
//file a.bat
12
123
456
13421
123456
//file b.bat
12
123
5432
123456
execute the command:
$ join -1 1 -2 1 -o '1.1 2.1' a.dat b.dat
12 12
123 123
where 123456 is ignored! In fact, i did try other files, some of them also didn’t get full results. why did it happen?
Your input needs to be lexically sorted in order for
jointo work correctly. Your input is numerically sorted, which is wrong. All strings which start with 1 should be before all strings which start with 2, etc.