2013-08-01 86 views
0

這裏是我的代碼grep的多個字符串搜索 - 分揀輸出

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!

回答

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 
+0

我收到錯誤訊息./wifiscan:行5:TAC:命令未找到。 – user2642132

+0

而不是'tac',說'sed'1!G; h; $!d'' – devnull