Is there any way to get the SSID of the current wireless network through a shell script on Mac OS X?
The following has been tested on OS X and prints the SSID without any hard-coded column widths:
system_profiler SPAirPortDataType | awk -F':' '/Current Network Information:/ {
getline
sub(/^ */, "")
sub(/:$/, "")
print
}'
Essentially, this takes the output of system_profiler SPAirPortDataType
, and prints the line after "Current Network Information:
" trimming leading whitespace and the trailing colon (since SSIDs can contain :
s).