[prog] tsch script problem, involves awk
Jimen Ching
jching at flex.com
Tue Dec 31 12:46:13 EST 2002
On Tue, 31 Dec 2002, Rebecca Erwin wrote:
>The problem is that major seems to end up being a string (cat
>/proc/devices...) instead of a number.
This is only a problem depending on what you plan to do with the $major
variable. Usually, I see script use the variable in a command like this:
mknod /dev/scull c $major 0
In this case, it doesn't matter that $major has a string, since it is part
of a command line. I wrote a simple script to test, and I was able to
perform simple arithmetic with the $major variable:
#! /bin/sh
module=alsa
major=`cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"`
echo major = $major
major=$(expr $major + 1)
echo major + 1 = $major
This script printed 116 and 117.
Just curious, what do you plan to do with this variable?
--jc
--
Jimen Ching (WH6BRR) jching at flex.com wh6brr at uhm.ampr.org
More information about the Programming
mailing list