There is a standard shell command "uname" which returns the current platform as a string
To use this in a shell program a typical stanza might be
#!/bin/sh
if [ `uname` = "Linux" ] ;
then
echo "we are on the operating system of Linux"
fi
if [ `uname` = "FreeBSD" ] ;
then
echo "we are on the operating system of FreeBSD"
fi
More specific information is available but unfortunately it varies according to platform. On many versions of Linux ( and ISTR, Solaris ) there is a /etc/issue file which has the version name and number for the distribution installed. So on ubuntu
if [ -e "/etc/issue" ] ;
then
issue=`cat /etc/issue`
set -- $issue
if [ $1 = "Ubuntu" ] ;
then
echo "we are on Ubuntu version " $2
fi
fi
This will give version information