Skip to main content

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>"

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/">//'

and just another tip anytime you find yourself doing

grep foo | awk

or

grep foo | sed

Do this instead

awk '/foo/{ print $3 }'

:)


@mm2270

sysctl -n hw.model