#TIL #macos #unix 명령어로 맥 모델 식별하기

$ curl -s http://support-sp.apple.com/sp/product?cc=`system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | cut -c 9-` | sed 's|.*<configCode>\(.*\)</configCode>.*|\1|'
MacBook Air (13-inch, Late 2010)

AWK 명령어로 Serial로 시작하는 줄에서 시리얼 번호를 추출. cut 명령어로 마지막 문자 4개만 남기고 잘라낸다. 응답으로 받은 문자열에서 <configCode> 태그 내용을 sed로 치환.

모델명 출력하고 나니 따끈따끈한 신상 맥북 사고 싶다.

참고

Feedback plz <3 @ohyecloudy, ohyecloudy@gmail.com

A Random Post