I have 2 files, I want to join them. they are both sorted. I sorted them by these commands:
$sort -n -k1,1 f1 > t1
$echo $?
0
$mv t1 f1
$sort -n -k1,1 f2 > t1
$echo $?
0
$mv t1 f2
now I run the join command
$join -1 1 -2 1 f1 f2 > fjoin
$echo $?
1
It says those files aren't sorted
$cat f1
0 0
5 0
9 0
10 0 <----- problem is here
$cat f2
0 1
3 1
11 2 <----- problem is here
I suggest to remove sort's option -n
.
From man join
:
Important: FILE1 and FILE2 must be sorted on the join fields. Eg, use
sort -k 1b,1
ifjoin
has no options, or usejoin -t ''
ifsort
has no options. Note, comparisons honor the rules specified byLC_COLLATE
. If the input is not sorted and some lines cannot be joined, a warning message will be given.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.