4

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.

5
/Sy*/L*/Priv*/Apple8*/V*/C*/R*/airport -I | grep SSID

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

1

Great answer here by grg, but just wanted to add this option in case it is useful for someone to extract the SSID and only the SSID:

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

and, airport is now in /usr/local/sbin/airport, which is likely in your $PATH, so this should be sufficient for most people:

airport -I | grep SSID | grep -v BSSID | awk '{print $2}'

  • I can confirm that the grep/awk pipeline works. But at least for me, on Mojave 10.14.2, airport is not in my /usr/local/sbin nor anywhere else on my $PATH. – dave4420 Jan 25 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .