Skip to content

Instantly share code, notes, and snippets.

@elecnix
Created September 24, 2014 03:15
Show Gist options
  • Save elecnix/182fa522da5dc7389975 to your computer and use it in GitHub Desktop.
Save elecnix/182fa522da5dc7389975 to your computer and use it in GitHub Desktop.
Parse iw scan output
# 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"]
}
}
@Djey1301
Copy link

@zehnm ur welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment