0

这是我的代码

iwlist wlan0 scan | grep -w "ESSID\|Quality"

它返回

                Quality=53/70  Signal level=-57 dBm
                ESSID:"NETGEAR00"
                Quality=50/70  Signal level=-60 dBm
                ESSID:"dlink_test"
                Quality=56/70  Signal level=-54 dBm
                ESSID:""
                Quality=49/70  Signal level=-61 dBm
                ESSID:"linksys"
                Quality=67/70  Signal level=-43 dBm

我想先按 ESSID 排序,然后是同一行的质量级别。

ESSID:"NETGEAR00"                  Quality=53/70  Signal level=-57 dBm

有什么建议么?Linux 新手!

4

1 回答 1

1

似乎您不想sort,而是简单地加入成对的行(第一行之前的第二行)。尝试:

iwlist wlan0 scan | grep -w "ESSID\|Quality" | tac | sed '$!N;s/\n/\t/'

对于给定的输入,它将产生:

ESSID:"linksys" Quality=49/70  Signal level=-61 dBm
ESSID:""    Quality=56/70  Signal level=-54 dBm
ESSID:"dlink_test"  Quality=50/70  Signal level=-60 dBm
ESSID:"NETGEAR00"   Quality=53/70  Signal level=-57 dBm
于 2013-08-01T13:22:30.817 回答