[prog] tsch script problem, involves awk

Rebecca Erwin rlerwin at fastertechnology.com
Tue Dec 31 10:40:51 EST 2002


These lines of code is taken straight from the O'Reilly Linux Device 
Drivers example programs.

#!/bin/sh
module="scull"
major='cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"'

Now if I understand things correctly, major will be assigned the value in 
the second field of a line where the first field is "scull".

For example given a /proc/devices file that has the following entries:
     hmmm   305
     foom      307
     scull      254

the value in major will end up being 254.

The problem is that major seems to end up being a string (cat 
/proc/devices...) instead of a number.

Thanks for any help you can provide.

--Rebecca





More information about the Programming mailing list