Skip to main content
Question

Extension Attributes to get the Model Identifier and Model ID Version number

  • July 24, 2012
  • 3 replies
  • 55 views

Forum|alt.badge.img+21

The following scripts work on Lion to grab the Model Identifier and also to strip out all but the Model Identifier Version number. To assist in the creation of smart groups, I'd recommend making the Model ID version number an integer. These have been tested under Mac OS X Lion only.

Good Luck and happy reconnoitering.

Model Identifier:

#!/bin/sh

echo "<result>$(system_profiler SPHardwareDataType | grep "Model Identifier" | awk '{print $3}')</result>"

Model Identifier Version number:

#!/bin/sh

echo "<result>$(system_profiler SPHardwareDataType | grep "Model Identifier" | tr -d [A-Z][a-z]:' ' | awk -F , '{print $1}')</result>"

3 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • July 24, 2012

You can also get the Model Identifier using ioreg, which is a bit faster than invoking System Profiler, like so-

ioreg -c IOPlatformExpertDevice | awk -F"= " '/model/{ print $2}' | sed -e 's/<"//;s/">//'

Forum|alt.badge.img+12
  • Contributor
  • July 24, 2012

and just another tip anytime you find yourself doing

grep foo | awk

or

grep foo | sed

Do this instead

awk '/foo/{ print $3 }'

:)


donmontalvo
Forum|alt.badge.img+36
  • Hall of Fame
  • January 30, 2019

@mm2270

sysctl -n hw.model