1
I have several linux computers sharing one disk and one home folder.
That is on the disk, there is the home folder: \home\wuciawe
And for computer A, whose os is Centos, it will load \home\wuciawe\.bashrc
For computer B, whose os is Ubuntu, it will load \home\wuciawe\.bashrc
, same with computer A.
Because I am not the Admin, I build and install some software locally on Ubuntu, and add something to the Path in \home\wuciawe\.bashrc
.
Due to some reason, something added to the Path draw a contradiction with Centos.
I wonder if there is a way to let the .bashrc know the current system, do something like follows:
if os is Ubuntu:
Path = xxx:$PATH
export PATH
endif
You can use the information here: http://unix.stackexchange.com/questions/35183/how-do-i-identify-which-linux-distro-is-running I wouldn't actually bother trying to parse these though. You should be able to simply check for the existence of files like
– krowe – 2015-01-08T06:55:24.380/etc/redhat-release
to determine if it is Red Hat, for example.1I normally have scripts which are hostname specific. e.g :
as I cant find reliable way to find OS across all linux distros, mac + cygwin, – Neil Wightman – 2015-01-09T09:18:59.353
1@NeilWightman This method looks greater as it can specify different computers with same os. – 宇宙人 – 2015-01-09T09:48:54.170
1I normally use a combination of
case $HOSTNAME
andcase $TERM
for all the combinations I need. – Neil Wightman – 2015-01-09T09:52:52.067