How can I check the RHEL version in Linux shell? What I need is to store it in a shell variable called MY_OS. How can it be done?
Run the following command to display RHEL or CentOS 8 version
Here is outputs from my CentOS 8 server:
CentOS Linux release 8.2.2004 (Core)
Another option to check the RHEL version
Use the grep command:
grep VERSION_ID /etc/os-release grep PRETTY_NAME /etc/os-release MY_OS="$(grep PRETTY_NAME /etc/os-release)" MY_OS_VERSION="$(grep VERSION_ID /etc/os-release)" echo "$MY_OS" echo "$MY_OS_VERSION"
See my page