Skip to content

Instantly share code, notes, and snippets.

@ltpitt
Created April 24, 2017 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltpitt/e6933ab06a8940c22f17d647ae52a331 to your computer and use it in GitHub Desktop.
Save ltpitt/e6933ab06a8940c22f17d647ae52a331 to your computer and use it in GitHub Desktop.
Function to check Distribution and Version of *nix Operating Systems
# OS check function
os_check ()
{
OS=`uname -rs`
if [ "`uname -rs | grep 'Linux 2.6.9'`" ]
then
OS=RHEL_4
elif [ "`uname -rs | grep 'Linux 2.6.18'`" ]
then
OS=RHEL_5
elif [ "`uname -rs | grep 'Linux 2.6.32'`" ]
then
OS=RHEL_6
elif [ "`uname -rs | grep 'SunOS 5.8'`" ]
then
OS=Sol_8
elif [ "`uname -rs | grep 'SunOS 5.9'`" ]
then
OS=Sol_9
elif [ "`uname -rs | grep 'SunOS 5.10'`" ]
then
OS=Sol_10
else
echo "OS cannot be identified, exiting..."
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment