The command
/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I
will give you details about your current wireless network connection.
To get specifically the SSID, use this command:
/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F: '/ SSID/{print $2}'
To retrieve SSID names that might have colons as well as spaces:
/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F' SSID: ' '/ SSID: / {print $2}'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…