Skip to content

Instantly share code, notes, and snippets.

@n1mh
Created November 30, 2016 12:20
Show Gist options
  • Save n1mh/d4835174325ca13b41b497aecce5a917 to your computer and use it in GitHub Desktop.
Save n1mh/d4835174325ca13b41b497aecce5a917 to your computer and use it in GitHub Desktop.
getting linux distro
#!/bin/bash
if [ "${OS}" = "Linux" ] ; then
KERNEL=`uname -r`
elif [ -f /etc/redhat-release ] ; then
DIST='RedHat'
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DIST='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DIST="Debian `cat /etc/debian_version`"
REV=""
fi
echo "Distro: $DIST"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment