Skip to content

Instantly share code, notes, and snippets.

@benbuckman
Created June 5, 2023 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbuckman/d3b1e1ce1fa9d7c42d31697ba19580ec to your computer and use it in GitHub Desktop.
Save benbuckman/d3b1e1ce1fa9d7c42d31697ba19580ec to your computer and use it in GitHub Desktop.
MacOS Remove unwanted preferred wifi networks
networksetup -listpreferredwirelessnetworks en0 | tail -n +2 | awk '{$1=$1};1' > ./wifi-networks-all.txt
cp ./wifi-networks-all.txt ./wifi-networks-keep.txt
# ... manually remove networks we DON'T want from wifi-networks-keep.txt ...
grep -Fvxf ./wifi-networks-keep.txt ./wifi-networks-all.txt > ./wifi-networks-remove.txt
networksetup -listallhardwareports
# ^ find wifi - probably `en0`
cat ./wifi-networks-remove.txt | while read network; do
echo "removing: $network"
networksetup -removepreferredwirelessnetwork 'en0' "$network" || break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment