这是我的代码
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 Newb!
答案 0 :(得分:1)
您似乎不想排序,而只是简单地连接线对(第一个之前的第二个)。尝试:
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