PDA

View Full Version : Model via Terminal




Äppelskrutt
Aug 6, 2013, 04:28 AM
Hi there!

Does anybody know a terminal command that gives me the the model of my Mac?

For example; "Late 2009" or "Early 2010".

That information does not exist in the SystemProfiler (/usr/sbin/system_profiler SPHardwareDataType). But in OS X 10.7 and OS X 10.8 you can see that information in "About this mac".

This would be very helpful for me.

Thanks:)



Macman45
Aug 6, 2013, 04:34 AM
Have you tried the "My Products" support page? If you registered your device with Apple it will appear here with all the info you need

Dalton63841
Aug 6, 2013, 04:49 AM
sysctl hw.model

starikarp
Aug 6, 2013, 04:58 AM
Hi there!

Does anybody know a terminal command that gives me the the model of my Mac?

For example; "Late 2009" or "Early 2010".

That information does not exist in the SystemProfiler (/usr/sbin/system_profiler SPHardwareDataType). But in OS X 10.7 and OS X 10.8 you can see that information in "About this mac".

This would be very helpful for me.

Thanks:)

sw_vers

and more information:

system_profiler | more

starikarp
**********
http://www.redbubble.com/people/lumiwa

Äppelskrutt
Aug 6, 2013, 05:00 AM
Hi,

Thanks for quick replies.

Sorry but "sysctl hw.model" is not was I was looking for.

I need a terminal command that gives me the year and if the model is late or early.

Example: "Late 2010"

And I need to get this via terminal.

Thanks

starikarp
Aug 6, 2013, 05:12 AM
Hi,

Thanks for quick replies.

Sorry but "sysctl hw.model" is not was I was looking for.

I need a terminal command that gives me the year and if the model is late or early.

Example: "Late 2010"

And I need to get this via terminal.

Thanks

system_profiler give a lot of information and one of this is also:
Model Name: iMac
Model Identifier: iMac11,1
Processor Name: Intel Core i7
Processor Speed: 2.8 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 8 MB
Memory: 8 GB
...
...

Use grep.

Äppelskrutt
Aug 7, 2013, 04:15 AM
Problem solved. Read about it here:

http://apple.stackexchange.com/questions/98080/can-a-macs-model-year-be-determined-via-terminal-command

If I put this script into Geektool it works great:

#!/bin/zsh -f

noglob 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|'

exit 0

Or this one:

#!/bin/zsh -f

# Original: http://apple.stackexchange.com/questions/98080/can-a-macs-model-year-be-determined-via-terminal-command
# This version slightly modified to remove XML. (See also: https://gist.github.com/tjluoma/6171647)


noglob 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|' |\
tr '[:cntrl:]' ' ' |\
sed 's#.*<configCode>##g ; s#</configCode>.*##g'

exit 0



Thanks all!