0

I have two files t1 and t2.

root@localhost:~#
root@localhost:~# cat t1
udp  UNCONN  0  0    0.0.0.0:68      0.0.0.0:*  users:(("dhclient",pid=479,fd=7))     479
tcp  LISTEN  0  128  127.0.0.1:6060  0.0.0.0:*  users:(("gggg-ruit",pid=24968,fd=5))  24968
root@localhost:~#
root@localhost:~# cat t2
root        88  0.0  0.0      0     0 ?        I<   Jan06   0:00 [scsi_tmf_0]
root        96  0.0  0.0      0     0 ?        I<   Jan06   0:00 [ipv6_addrconf]
root     24965  0.0  0.2  11592  3004 ?        S    Jan12   0:00 bash /root/restart_gggg.sh
root     24968  0.7  5.2 112488 53472 ?        Sl   Jan12  30:52 /usr/local/bin/gggg-ruit -singleInstance :44444

I want to join them on the 8th column of t1 and the 2nd column of t2. I already have them in sorted order. Let's prove it.

root@localhost:~# awk '{print $8}' t1
479
24968
root@localhost:~# awk '{print $2}' t2
88
96
24965
24968

Now when I join them, I got the following error.

root@localhost:~# join -1 8 -2 2 -o 2.1,2.2,1.1,1.2,1.5,1.6,2.11 t1 t2
join: t2:3: is not sorted: root     24965  0.0  0.2  11592  3004 ?        S    Jan12   0:00 bash /root/restart_gggg.sh
root@localhost:~#

Why it tells me t2 is not sorted on row 3? As you can see, it's been already sorted on the join column.

4

They’re sorted numerically, but join requires them to be sorted lexicographically: 24968, then 479; and 24965, 24968, 88, then 96.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.