How to check installed OS X version from the command-line on each partition? I'm managing a lot of Macs and each machines has several partitions with different OS versions.

I would like to create a script that I could run to do an inventory of all partitions of all machines and take note what OS is installed on each partition.

On the active partition, it would be easy to get it via the sw_vers command. But what about on a different partition?
The following command will give you the OS X version installed on  volumeName:

defaults read /Volumes/volumeName/System/Library/CoreServices/SystemVersion ProductVersion


To get a list of each volume's OS version, you need a simple script that will get a list of volumes, search each one for the SystemVersion.plist, and report any that are found.

I found a script on on Mac OS X Hints, by Hal Itosis, that does just that (reposted below for convenience).

#!/bin/bash -
PATH=/bin:/usr/bin
export PATH
IFS=$'\n'

vList=$(df -l | sed '1d;s:^.*%[[:space:]]*::')
sPath=$(find -x /Volumes -maxdepth 1 -type l -not -inum 2)
pFile=/System/Library/CoreServices/SystemVersion

SysVers ()
{
   if [ -e "${1}${pFile}.plist" ]; then
      n="$1"; if [ "$1" = '/' ]; then n="$sPath"; fi
      x=`defaults read ${1}${pFile} ProductVersion`
      b=`defaults read ${1}${pFile} ProductBuildVersion`
      printf '%-16s %-8s %-8s\n' "${n##/*/}" "$x" "($b)"
   fi
}

if [ $# -eq 0 ]; then for v in $vList; do SysVers "$v"; done
else while [ $# -gt 0 ]; do SysVers "$1"; shift; done; fi
exit