how can I recognize which OS I am on in a bash script

<>

This question already has an answer here:

Answers


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


Need Your Help

Need to define a workflow/process that integrates SW dev. all the way through Conf. Management

mercurial process workflow clearcase

We have a group of ~10 devs. who write internal test SW only. Until now, all development has been ad hoc with only a couple developers using Mercurial in their own way. The rest of the people use...

resharper hotkey: subclasses that override certain method

resharper

Suppose I select some method and I want to open a tree in which I want to see all subclasses that override this method. What hotkey is used for this in Resharper? In Eclipse I use Ctrl+T for this

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.