André Amorim

Crafting Web Experiences

//

Get current operating system with a Bash script


OS="Unknown"
if [[ "$OSTYPE" == "linux-gnu" ]];then
    OS="Linux"
elif [[ "$OSTYPE" == "darwin"* ]];then
    OS="MacOS"
elif [[ "$OSTYPE" == "cygwin" ]];then
    
    OS="cygwin"
elif [[ "$OSTYPE" == "msys" ]];then
    
    OS="msys"
elif [[ "$OSTYPE" == "win32" ]];then
    OS="Win32"
elif [[ "$OSTYPE" == "freebsd"* ]];then
    OS="FreeBSD"
fi
echo "Operating System: $OS"

Published date:

Modified date: