I am looking for a command that will return the kernel build without the architecture.
uname -r returns: 2.6.32-279.22.1.el6.x86_64 but I only need 2.6.32-279.22.1.el6
I can do this using a regex and chomp everything past the last dot
On
I'm not sure how portable it is but you could do the following --
uname -r | sed s/\.`arch`//
example -
$ uname -r
2.6.32-358.6.2.el6.x86_64
$ uname -r | sed s/\.`arch`//
2.6.32-358.6.2.el6
On
You can't avoid it. During the kernel build, with the help of "Local version - append to the kernel release" (http://lxr.linux.no/linux+*/init/Kconfig#L56) configuration option these extra "el6.x86_64" are set and mainly to track build and release versions.
So, a possible workaround is like below:
uname -a | awk '{print $3}'
Given that regex can be used, you can match the string against
^(.*)\.[^.]*$and take the first capture group.(
(.*)\..*will generally also work, with "greedy" quantifiers, but cf. a reference for your regex engine.)