-
-
Save zjm1060/fe7c24863e0e19f5fadfa31300ce66d5 to your computer and use it in GitHub Desktop.
Parse iw scan output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f scan.awk | |
$1 == "BSS" { | |
MAC = $2 | |
print $2 | |
e = wifi[MAC] | |
e["enc"] = "Open" | |
} | |
$1 == "SSID:" { | |
e = wifi[MAC] | |
e["SSID"] = $2 | |
} | |
$1 == "freq:" { | |
e = wifi[MAC] | |
e["freq"] = $NF | |
} | |
$1 == "signal:" { | |
e = wifi[MAC] | |
e["sig"] = $2 " " $3 | |
} | |
$1 == "WPA:" { | |
e = wifi[MAC] | |
e["enc"] = "WPA" | |
} | |
$1 == "WEP:" { | |
e = wifi[MAC] | |
e["enc"] = "WEP" | |
} | |
END { | |
printf "%s\t\t%s\t%s\t\t%s\n","SSID","Frequency","Signal","Encryption" | |
for (w in wifi) { | |
e = wifi[w] | |
printf "%s\t\t%s\t\t%s\t%s\n",e["SSID"],e["freq"],e["sig"],e["enc"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment