Last active
January 19, 2024 09:49
-
-
Save gmolveau/d0e3efc219c5bcc6ecc13a1405ac6c73 to your computer and use it in GitHub Desktop.
Bash/shell script detect/check OS and distribution (+WSL Windows Subsystem for Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
local DISTRIB=$(awk -F= '/^NAME/{print $2}' /etc/os-release) | |
if [[ ${DISTRIB} = "Ubuntu"* ]]; then | |
if uname -a | grep -q '^Linux.*Microsoft'; then | |
# ubuntu via WSL Windows Subsystem for Linux | |
else | |
# native ubuntu | |
fi | |
elif [[ ${DISTRIB} = "Debian"* ]]; then | |
# debian | |
fi | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
# macOS OSX | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good stuff, However, I had an issue with SteamOS. it detects as "SteamOS" and won't load. fixed it by putting an asterisk in front of the OS Name