detecting version of linux
Posted on 2003-03-17
We have a shell script that currently asks if the user is running Debian, Red Hat, or SUSE, and adapts a makefile accordingly. (I think Red Hat may be the oddman out.) We'd like to determine what distribution of Linux they're running.
A short and acceptable (and wonderful) answer might be a snippet of shell script (including the #! at the top) that should run on all those flavors of Linux, and do the follow pseudocode: (I think the existing script runs under ksh and bash? Does Linux not usually come with ksh?)
I'm not sure what the most reliable way of detecting dist is; though gcc -v seems to work. But then I'm not sure how to redirect it's stderr to stdout under ksh and/or bash, and my shell scripting is weak enough that I don't know the easiest way of checking the result of that grep, so any advice on that would be appreciated as well...