现在的位置: 首页 > 综合 > 正文

shell中的反引号与$()区别

2013年10月10日 ⁄ 综合 ⁄ 共 687字 ⁄ 字号 评论关闭

 今天在现在了ldd3的代码,运行scull中的scull_load的时候弹出如下错误:

[root@localhost scull]# ./scull_load
awk: cmd. line:1: /=="scull" {print /}
awk: cmd. line:1: ^ backslash not last character on line
mknod: wrong number of arguments

因为代码是刚刚从书中推荐的ftp://ftp.ora.com/pub/examples/linux/drivers/下载的,由于里面没有ldd3的代码,所以下载的ldd2的代码,其中的readme.txt提示可以到作者的网址ftp://ar.linux.it/pub/ldd2/去下载,我到里面得到了ldd3的代码,解压执行就出现了上面的错误提示。

后来经过对比验证才知道问题出在scull_load里面的

major=$(awk "//$2==/"$module/" {print
//$1}" /proc/devices)

将其修改为

major=$(awk "/$2==/"$module/" {print
/$1}" /proc/devices)

运行就没有问题了;或者修改为(注意是反引号)

major=’awk "//$2==/"$module/" {print
//$1}" /proc/devices‘

也没有问题。

参考资源:

http://iwillfy2003.blog.sohu.com/60815550.html

http://www.lslnet.com/linux/dosc1/34/linux-258105.htm

抱歉!评论已关闭.