我在本書[linux設備驅動程序]中閱讀了這行腳本。任何人都可以幫助解釋它的作用嗎(可能是一些細節)?這個shell腳本行與awk的含義
major=$(awk "\\$2= =\"$module\" {print \\$1}" /proc/devices)
如在上下文中:
#!/bin/sh
module="scull"
device="scull"
mode="664"
# invoke insmod with all arguments we got
# and use a pathname, as newer modutils don't look in . by default
/sbin/insmod ./$module.ko $* || exit 1
# remove stale nodes
rm -f /dev/${device}[0-3]
major=$(awk "\\$2= =\"$module\" {print \\$1}" /proc/devices)
mknod /dev/${device}0 c $major 0
....
無論本書你讀到,在,燒了它。該腳本中至少有一半的行至少有一個錯誤,並且它調用awk的方式只是荒謬的。 –
@EdMorton好心推薦一本替換書... –
For shell:Shell腳本食譜作者:Chris Johnson。對於awk:Arnold Robbins的有效Awk編程。感謝cbuckley –