谁能详细解析一下这行带awk命令的SHELL脚本

梦想照旧实现 2017-03-09 09:54:38
#!/bin/sh
# $Id: scull_load,v 1.4 2004/11/03 06:19:49 rubini Exp $
module="scull"
device="scull"
mode="664"

# Group: since distributions do it differently, look for wheel or use staff
if grep -q '^staff:' /etc/group; then
group="staff"
else
group="wheel"
fi

# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default
/sbin/insmod ./$module.ko $* || exit 1

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


按照shell的语法和awk的特性,解析一下下面这行shell脚本
major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
...全文
712 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
梦想照旧实现 2017-04-12
  • 打赏
  • 举报
回复
懂了,多谢!
qprevf 2017-03-11
  • 打赏
  • 举报
回复
根据device里的第二列内容,找个与scull这个名称相同的设备的设备号

1,318

社区成员

发帖
与我相关
我的任务
社区描述
主要是开发驱动技术
社区管理员
  • 驱动程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧