Sponsored Content
Top Forums Shell Programming and Scripting Linux kernel version comparision method Post 302909683 by veeresh_15 on Friday 18th of July 2014 09:01:22 AM
Old 07-18-2014
I think i figured out the code to compare kernel & rpm version's on Redhat Linux.
Below is the code that i have written and tested for various RPM's & kernel version.

Code:
expected_ver=2.6.32-279.el6.x86_64
received_ver=2.6.32-279.39.1.el6.x86_64

expected_v=$(echo $expected_ver|awk -F'.' '{if($NF ~ /[xi]*86/ && $(NF-1) ~ /el/) NF=NF-2; else if ($NF ~ /[xi]*86/ && $(NF-1) !~ /el/) NF=NF-1; else if ($NF ~ /el/) NF=NF-1; for (i=1;i<=NF;i++) printf $i".";}'|sed 's/.$//')

received_v=$(echo $received_ver|awk -F'.' '{if($NF ~ /[xi]*86/ && $(NF-1) ~ /el/) NF=NF-2; else if ($NF ~ /[xi]*86/ && $(NF-1) !~ /el/) NF=NF-1; else if ($NF ~ /el/) NF=NF-1; for (i=1;i<=NF;i++) printf $i".";}'|sed 's/.$//')

if [ "$expected_v" = "$received_v" ]; then
	echo "Installed Version is same than Expected."
    echo "Passed."
else
	min=$(echo -e $expected_v"\n"$received_v|sort -V|head -n 1)
	if [ "$min" = "$expected" ];then
       echo "Installed Version is higher than Expected."
       echo "Passed."
	else
       echo "== FAILED == Received output is not as expected."
	fi
fi

 

10 More Discussions You Might Find Interesting

1. Linux Benchmarks

Dual Xeon 2.6, RedHat EL 4 ES, up to latest release version. 2.6.9 kernel

============================================================== BYTE UNIX Benchmarks (Version 3.11) System -- Linux linux.hhc.ac.uk 2.6.9-11.ELsmp #1 SMP Fri May 20 18:26:27 EDT 2005 i686 i686 i386 GNU/Linux Start Benchmark Run: Wed Jul 6 15:06:07 BST 2005 1 interactive users.... (2 Replies)
Discussion started by: Garp
2 Replies

2. Linux

kernel version

Hi all, anyone know what should be the kernel version for red hat linux enterprise 3 update 3 . I have installed kernel version is 2.4.21-4 and some says that it may not be the red hat linux enterprise 3 update 3 . :o thanks Bert (4 Replies)
Discussion started by: bert.n
4 Replies

3. Solaris

How can i see kernel patch version?

Hello experts. How can i see kernel patch version? what are advantages applying that patch? Thanx in advance (5 Replies)
Discussion started by: younus_syed
5 Replies

4. Debian

how to find out the kernel version of a particular debian release ?

Is there any metrics table available somewhere listing out, which kernel version is there in particular debian release ? Also, can somebody tell which debian release is having the kernel version 2.6.26 ? (1 Reply)
Discussion started by: thegeek
1 Replies

5. Shell Programming and Scripting

Incorrect kernel version (why).

ps -A | grep firefox | kill `awk '{print $1}'` Warning: /boot/System.map-2.6.35.11-83.fc14.x86_64 has an incorrect kernel version. The command have succeeded but with the warning. The command before the previous one had not been successful. But there was also this warning. (1 Reply)
Discussion started by: Xcislav
1 Replies

6. Red Hat

Downgrade kernel version with yum

Dear all, Now I need to downgrade my current kernel to 2.6.12 I found some pages with Google, and they said that I can do it with yum, but there is not details information. How can I use yum to downgrade kernel version :wall: Please help me Thank you very much (4 Replies)
Discussion started by: Hannibal2010
4 Replies

7. Solaris

about the Kernel version ?!!

Hi All I have the below information ... and I want to know how to get the lats Kernel version ? and is this Kernel version SunOS 5.10 Generic_147440-13 last version or what ? - Hostname: server1 Release: 5.10 Kernel architecture: sun4u Application architecture: sparc Hardware... (1 Reply)
Discussion started by: roooooot
1 Replies

8. Shell Programming and Scripting

get the perl version (decimal value comparision)

Hi All, can you pls throw some light for below logic -> Check the perl version -> if the version is greater than or equal to 5.8 -> proceed to next step -> else fail Regards Kamal (2 Replies)
Discussion started by: kamauv234
2 Replies

9. Red Hat

Kernel version required for installing KVM

Hi friends, I have a created a RHEL 6.4 for installing KVM in Virtual box. My machine is a 64 bit, but virtual box was not allowing to install x86_64 version RHEL. So I had to install 32 bit i686 version of RHEL. The kernel came with the CD was 2.6.32-358.el6.i686. But KVM doesnt support... (2 Replies)
Discussion started by: shyam2j
2 Replies

10. HP-UX

Regarding firmware and kernel version of HP-UX systems.

Dear All, Please help to find out the patch and firmware versions in HP-UX systems. as uname -r is showing os version and uname -a HP-UX xxxxxx B.11.23 U 9000/800 2781427196 unlimited-user license. Kindly help to find out the existing Kernel and firmware versions. Also I need to... (3 Replies)
Discussion started by: anuragr
3 Replies
SETARCH(8)						       System Administration							SETARCH(8)

NAME
setarch - change reported architecture in new program environment and set personality flags SYNOPSIS
setarch <arch> [options] [program [arguments]] arch [options] [program [arguments]] DESCRIPTION
setarch This utility currently only affects the output of uname -m. For example, on an AMD64 system, running 'setarch i386 program' will cause 'program' to see i686 (or other relevant arch) instead of x86_64 as machine type. It also allows to set various personality options. The default program is /bin/sh. OPTIONS
-v, --verbose Be verbose. -h, --help Display help (it is also displayed when setarch takes no arguments). -V, --version Output version information and exit. --uname-2.6 Causes the program to see a kernel version number beginning with 2.6. -3, --3gb Specifies that processes should use a maximum of 3GB of address space on systems where it is supported (ADDR_LIMIT_3GB). --4gb Ignored (for backward compatibility only). --list List architectures that can be set. -B, --32bit Turns on ADDR_LIMIT_32BIT. -F, --fdpic-funcptrs Userspace function pointers point to descriptors (turns on FDPIC_FUNCPTRS). -I, --short-inode Turns on SHORT_INODE. -L, --addr-compat-layout Changes the way virtual memory is allocated (turns on the ADDR_COMPAT_LAYOUT). -R, --addr-no-randomize Disables randomization of the virtual address space (turns on ADDR_NO_RANDOMIZE). -S, --whole-seconds Turns on WHOLE_SECONDS. -T, --sticky-timeouts Turns on STICKY_TIMEOUTS. -X, --read-implies-exec Turns on READ_IMPLIES_EXEC. -Z, --mmap-page-zero Turns on MMAP_PAGE_ZERO. EXAMPLES
setarch ppc32 rpmbuild --target=ppc --rebuild foo.src.rpm setarch ppc32 -v -vL3 rpmbuild --target=ppc --rebuild bar.src.rpm setarch ppc32 --32bit rpmbuild --target=ppc --rebuild foo.src.rpm AUTHOR
Elliot Lee <sopwith@redhat.com> Jindrich Novy <jnovy@redhat.com> AVAILABILITY
The setarch command is part of the util-linux package and is available from Linux Kernel Archive <ftp://ftp.kernel.org/pub/linux/utils /util-linux/>. util-linux September 2011 SETARCH(8)
All times are GMT -4. The time now is 12:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy