How to find “file-release” in OS X El Capitan 10.11.6

filesystem

I can not find file-release through command line on OS X El Capitan Version 10.11.6. On my virtual machine in Ubuntu I can do "ls /etc/*release" and it shows me two files with all needed information:

$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.0 (Maipo)

$ cat /etc/os-release 
NAME="Red Hat Enterprise Linux Server"
VERSION="7.0 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.0"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.0 (Maipo)"

No idea how to find the file with release information on Mac. Please give me a hint or a hint how to search it?

Best Answer

  • The file(s) /etc/*release contain OS specific informations like distribution name and version mainly in Linux distributions.

    One of the purpose of the file(s) is to help software to detect the distribution type.

    A file which contains similar informations doesn't really exist in OS X/macOS but can be mimicked with the following shell script:

    #!/bin/sh
    
    OS=`uname -s`
    REV=`uname -r`
    MACH=`uname -m`
    if [ "${OS}" = "Darwin" ]; then
        OIFS="$IFS"
        IFS=$'\n'
        set `sw_vers` > /dev/null
        DIST=`echo $1 | tr "\n" ' ' | sed 's/ProductName:[ ]*//'`
        VERSION=`echo $2 | tr "\n" ' ' | sed 's/ProductVersion:[ ]*//'`
        BUILD=`echo $3 | tr "\n" ' ' | sed 's/BuildVersion:[ ]*//'`
        OSSTR="${OS} ${DIST} ${REV}(SORRY_NO_PSEUDONAME ${BUILD} ${MACH})"
        IFS="$OIFS"
    fi
    echo ${OSSTR}
    

    Executing the script in my system will yield:

    Darwin Mac OS X 13.4.0(SORRY_NO_PSEUDONAME 13F1911 x86_64)
    

    In OS X/macOS the file is not needed because the requirements of a software package are determined by other means:

    • Info.plist in an installer app (e.g. Install macOS Sierra.app requires LSArchitecturePriority=x86_64 or LSMinimumSystemVersion=10.7)
    • preflight scripts in an installer packages which use sw_vers or similar commands to determine the OS version.