Created
February 26, 2015 20:01
-
-
Save jacobsalmela/9fe37501ca9f2144dfdf to your computer and use it in GitHub Desktop.
Remove an SSID from the preferred networks list
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
#!/bin/bash | |
#----------VARIABLES--------- | |
undesiredNetwork="SSID-To-Remove" | |
wifiOrAirport=$(/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(Wi-Fi|AirPort)') | |
echo $wifiOrAirport | |
wirelessDevice=$(networksetup -listallhardwareports | awk "/$wifiOrAirport/,/Device/" | awk 'NR==2' | cut -d " " -f 2) | |
echo $wirelessDevice | |
#-----------SCRIPT----------- | |
# Remove the SSID from the list of preferred networks | |
networksetup -removepreferredwirelessnetwork "$wirelessDevice" "$undesiredNetwork" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment