Search This Blog

BASH check os type

if [[ "$OSTYPE" == "linux-gnu" ]]; then
    echo linux
elif [[ "$OSTYPE" == "darwin"* ]]; then
    echo mac_os
elif [[ "$OSTYPE" == "cygwin" ]]; then
    echo windows
elif [[ "$OSTYPE" == "msys" ]]; then
    echo windows
elif [[ "$OSTYPE" == "win32" ]]; then
    echo windows
elif [[ "$OSTYPE" == "freebsd"* ]]; then
    echo freebsd
else
    echo unknown
fi

No comments:

Post a Comment