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


this question has answer here:

i need make script behaves differently per system. today possible run bash on microsoft windows, mac, linux, hp-ux, solaris etc...

how can determine of these operating systems on? don't need exact version, need know if on windows, linux, solaris...

there standard shell command "uname" returns current platform string

to use in shell program typical stanza might be

#!/bin/sh    if [ `uname` = "linux" ] ;     echo "we on operating system of linux" fi  if [ `uname` = "freebsd" ] ;     echo "we on operating system of freebsd" fi 

more specific information available unfortunately varies according platform. on many versions of linux ( , istr, solaris ) there /etc/issue file has version name , number distribution installed. on ubuntu

if [ -e "/etc/issue" ] ; issue=`cat /etc/issue` set -- $issue if [ $1 = "ubuntu" ] ;     echo "we on ubuntu version " $2 fi fi 

this give version information


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -