0

When I use the graphical interface to NetworkManager (via the tray icon), it displays around 10 SSIDs (for my current location). However, when I use nmcli dev wifi it returns around 55 entries. The reason is that the same SSID is returned multiple times with different signal strength (and sometimes even different transfer rate). Most of the duplicate SSIDs have distinct channels/bands, but some have the same.

Sample output

IN-USE  SSID               MODE   CHAN  RATE        SIGNAL  BARS  SECURITY    
        G4_9647            Infra  11    65 Mbit/s   84      ▂▄▆█  WPA2        
        Telekom            Infra  11    130 Mbit/s  64      ▂▄▆_  --          
        Airport-Frankfurt  Infra  11    130 Mbit/s  62      ▂▄▆_  --          
        FRAWiSe            Infra  11    130 Mbit/s  60      ▂▄▆_  WPA2 802.1X 
        FRAWiSe            Infra  48    405 Mbit/s  60      ▂▄▆_  WPA2 802.1X 
        Airport-Frankfurt  Infra  48    405 Mbit/s  60      ▂▄▆_  --          
        Ca81pVb5jKTw       Infra  11    130 Mbit/s  59      ▂▄▆_  WPA2        
        Telekom            Infra  48    405 Mbit/s  59      ▂▄▆_  --          
        Airport-Frankfurt  Infra  36    270 Mbit/s  57      ▂▄▆_  --          
        Telekom            Infra  36    270 Mbit/s  55      ▂▄__  --          
        FRAWiSe            Infra  36    270 Mbit/s  55      ▂▄__  WPA2 802.1X 
        Ca81pVb5jKTw       Infra  11    130 Mbit/s  54      ▂▄__  WPA2        
        AndroidAP 3        Infra  6     65 Mbit/s   50      ▂▄__  WPA2        
        FRAWiSe            Infra  11    130 Mbit/s  50      ▂▄__  WPA2 802.1X 

The following commands also lists around 55 connections

sudo iwlist wlp4s0 scan | grep ESSID
sudo iw dev wlp4s0 scan | grep SSID

How can I achieve the same result from using nmcli as with the NetworkManager GUI and limit the results to one entry per unique SSID? I would like to achieve this without knowing which channel/band the SSIDs are on (in which case I could just use grep). For example, returning just the entry with the channel/band that has the highest signal strength.

1
nmcli dev wifi | awk -F'  +' '{ if (!seen[$2]++) print}'

The awk script works as follows:

  • -F' +' - Separator is two or more spaces
  • If the 2nd column (SSID) has not been seen previously then print. Then add 1 to that value so that next time it's not printed
  • Great, thank you! The only downside is that the colorized text output is not retained after piping through awk. Any idea how to fix that? Seems like it's not just passed as ANSI color codes – joelostblom Dec 19 '18 at 14:31

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.