how can I recognize which OS I am on in a bash script -
this question has answer here:
- detect os bash script 18 answers
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
Post a Comment