Discussion Locked

Shell Scripting

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am needing a way for a script file to detect which version of Red Hat is running and assign it to a variable. I am fairly sure I know how to assign the variable but if someone would throw that in I'd appreciate it.

3 replies

by joe prochazka

the version information can be found it the file /etc/redhat-release

So to display the version of your machine you could run a script like so:

#!/bin/sh
S=$(cat /etc/redhat-release)
echo "This is $S"

This script takes the output of /etc/redhat-release and asigns it so that whenever $S is used in the script $S will actually be the version your running.

This discussion is closed to new replies.