On 6/26/06, Benjamin Reed <[EMAIL PROTECTED]> wrote:
-----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.

Teacher! Teacher!

I'm missing something here, in my case both forms of the -f parm give
the same results:

[EMAIL PROTECTED]:~$ uname -r
2.6.15-25-686
[EMAIL PROTECTED]:~$ uname -r | cut -d. -f3-
15-25-686
[EMAIL PROTECTED]:~$ uname -r | cut -d. -f3
15-25-686


Rick DeNatale

IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/
--
TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ  : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/

Reply via email to