Skip to content

Instantly share code, notes, and snippets.

@miyako-ep miyako-ep/check_os
Last active Jan 31, 2018

Embed
What would you like to do?
OSがどれかチェックします
#!/usr/bin/sh
# mac
if [ ! -z "$(command -V sw_vers 2>/dev/null)" ]; then
# I am Mac
fi
# Ubuntu
cat /etc/issue | grep "Ubuntu" 2>&1 1>/dev/null
if [ $? -eq 0 ]; then
# I am Ubuntu
fi
# Debian
cat /etc/issue | grep "Debian" 2>&1 1>/dev/null
if [ $? -eq 0 ]; then
# I am Debian
fi
# CentOS
if [ -e "/etc/redhat-release" ]; then
# I am CentOS
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.