[TriLUG] detecting kernel major/minor versions
Benjamin Reed
rangerrick at befunk.com
Mon Jun 26 21:03:12 EDT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Joseph Mack NA3T wrote:
> uname_r=`uname -r`
> minor_and_subminor=${uname_r##*2.6.}
> minor=${minor_and_subminor%\.*}
Bash stuff works, although this will fail when 2.7 comes out... <grin>
I generally use "cut" for such things, it tends to be more future-proof:
minor_and_subminor=`echo $uname_r | cut -d. -f3-`
minor=`echo $uname_r | cut -d. -f3`
- -d. means chop up the string on the "."s
- -f3 means display the 3rd entry in the chopped string
- -f3- means display the 3rd entry and anything afterwards
you could also do "-f3-4" to specifically ask for the 3rd through the 4th.
- --
Benjamin Reed a.k.a. Ranger Rick
http://ranger.befunk.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEoIPPUu+jZtP2Zf4RAmxrAJ0QKpYLt7al3ykSMk/2V2Vu8TDkbACcDZ/K
x1300Ph+L9f6lRYdRv/79yw=
=amGY
-----END PGP SIGNATURE-----
More information about the TriLUG
mailing list