Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Äppelskrutt

macrumors newbie
Original poster
Aug 6, 2013
3
0
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:)
 

Attachments

  • Skärmavbild 2013-08-06 kl. 11.26.47.png
    Skärmavbild 2013-08-06 kl. 11.26.47.png
    21.5 KB · Views: 402

starikarp

macrumors member
Apr 27, 2013
83
4
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

macrumors newbie
Original poster
Aug 6, 2013
3
0
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

macrumors member
Apr 27, 2013
83
4
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

macrumors newbie
Original poster
Aug 6, 2013
3
0
Problem Solved

Problem solved. Read about it here:

http://apple.stackexchange.com/ques...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/ques...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!
 

Attachments

  • Skärmavbild 2013-08-07 kl. 11.12.09.png
    Skärmavbild 2013-08-07 kl. 11.12.09.png
    30.4 KB · Views: 125
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.