need a good way to determine the OS from a BASH script

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Mar 22 17:11:03 UTC 2011


On Tue, Mar 22, 2011 at 01:06:18PM -0400, Lennart Sorensen wrote:
> On Tue, Mar 22, 2011 at 11:15:39AM -0400, Digimer wrote:
> > On 03/22/2011 11:07 AM, Vic Gedris wrote:
> > > "uname" is your friend for this.
> > > 
> > > $ uname
> > > Linux
> > > 
> > > $ uname
> > > SunOS
> > > 
> > > ..etc..  Not sure what it reports for MacOS...
> > 
> > OS X returns the name of the OS X release (ie: Darwin), and no
> > /etc/issue exists. Look into /etc/lsb_release (man 1 lsb_release).
> 
> How about uname -s or uname -o?

Or better yet:

cat /dev/null | cpp -dM

On linux you see something like:

#define linux 1

I am sure Mac OS X defines something similar.

Also Darwin is the name of the Mac OS X kernel, not a release.  All Mac
OS X releases use a kernel named Darwin.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list