'join'ユーティリティレポート:ファイルはソートされていませんが、実際にはソートされました。

'join'ユーティリティレポート:ファイルはソートされていませんが、実際にはソートされました。

t12つのファイルがあります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

t1の8列とt2の2列に結合したいです。私はそれらを順番にまとめました。それを証明しましょう。

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

今すぐjoin使用すると、次のエラーが発生します。

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:~#

t2が行3にソートされていないと言うのはなぜですか?ご覧のとおり、すでに結合列に配置されています。

ベストアンサー1

数字でソートされますが、join辞書順(24968、479、24965、24968、88、96)が必要です。

おすすめ記事