Re: [Nolug] Major kernel version, or "extracting substring from a symbol"

From: scotth_at_scottharney.com
Date: Thu, 26 Feb 2004 07:53:56 -0600
Message-ID: <87hdxeeykr.fsf@minorthreat.local.lan>

Ron Johnson <ron.l.johnson@cox.net> writes:

> Hi,
>
> We all know that "uname -r" gives the exact kernel version. How
> do I extract out the "2.4"?

Do you have the "kernelversion" command? It exists on my
debian and gentoo boxes.

In any case, "kernelversion" is this shell script:

#!/bin/sh
# Small script to get the kernel version
# Made by W.Akkerman <wichert@liacs.nl> for the Debian modules package.

# Helper functions from Bruce Perens to replace cut

pick1() {
    eval 'echo $'"$pick_index"
}
pick() {
    OLD_IFS=IFS
    local delimiter="$1"
    shift
    pick_index="$1"
    shift
    IFS=" "$delimiter
    pick1 $*
    IFS=$OLD_IFS
    unset pick_index
}

version=$(uname -r)
echo `pick . 1 $version`.`pick . 2 $version`

> The reason I ask is that there are certain steps in my PC's boot
> process that I only want to run if I'm booting into 2.4 (and I'm
> sure there will also be some if I'm booting into 2.6).

-- 
Scott Harney<scotth@scottharney.com>
"...and one script to rule them all."
gpg key fingerprint=7125 0BD3 8EC4 08D7 321D CEE9 F024 7DA6 0BC7 94E5
___________________
Nolug mailing list
nolug@nolug.org
Received on 02/26/04

This archive was generated by hypermail 2.2.0 : 12/19/08 EST