MacOS – How to get the name of the wifi network I’m connected to

command linemacosNetworkwifi

I know how to find it out in Objective C, but I need to do this in a shell script.

(I could compile and install one of the example programs given in the link, but surely there is already a command line program installed that will give me this information?)

I have MacOS X Yosemite, 10.10.2.

Best Answer

/Sy*/L*/Priv*/Apple8*/V*/C*/R*/airport -I | awk '/ SSID:/ {print $2}'

This uses the airport CLI, with the -I flag to show information and filter using awk for just the SSID shows the name of the network.