Finding about which OS is running via shell script
Paul Smith
paul at mad-scientist.net
Fri Apr 26 19:53:00 UTC 2013
On Fri, 2013-04-26 at 22:46 +0300, Kevin Wilson wrote:
> My aim is to right a script that will behave differently
> when running it on Fedora or running it on Ubuntu.
> Is there a way to know from Bash whether the OS is ubuntu or
> Fedora (besides parsing /etc/issue ) ?
All LSB-compliant distributions will support the lsb_release command.
See the man page.
$ lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.3 (Final)
Release: 6.3
Codename: Final
$ lsb_release -s -i
CentOS
$ lsb_release -s -r
6.3
More information about the ubuntu-users
mailing list