首页 > 技术文章 > Linux 准确查找结构体定义位置

lialong1st 2018-03-28 14:36 原文

例如:查找文件操作结构体 struct file_operations,

使用转移符 "\" 

$ grep struct\ file_operations\ { kernel/include/ -rn

使用双引号

$ grep "struct file_operations {" kernel/include/ -rn

 

下面这种方式,会查找到所有含有 file_operations 的结构体,包括定义,声明,使用。

$ grep file_operations kernel/include/ -rn

下面这种方式,只会匹配struct,所以含有struct的都会显示。

$ grep struct file_operations { kernel/include/ -rn

 

推荐阅读