我想查找某个函数在哪几个文件中出现,给个shell语句把。
好像以前问过别人,忘了。
比如在/usr/include 中所有的头文件中查找socket函数出现的地方,在线等
求个shell语句
- xhy
- 帖子: 3916
- 注册时间: 2005-12-28 1:16
- 系统: Ubuntu 12.10 X64
- 来自: 火星
- keky
- 帖子: 231
- 注册时间: 2007-12-20 15:08
- 来自: harbin
- 联系:
Re: 求个shell语句
#!/bin/bash
str=$1
for file in `ls`
do
if( grep $str $file );then
echo "filename========>"$file
fi
done
str=$1
for file in `ls`
do
if( grep $str $file );then
echo "filename========>"$file
fi
done
- hellojinjie
- 帖子: 1150
- 注册时间: 2007-09-14 21:03
- 来自: 浙江
Re: 求个shell语句
LS的为什么不直接
grep -n something ./*
如果要看子目录的话 ,
grep -nr something ./*
这个在看代码的时候很有用的,特别是没有IDE的情况下
grep -n something ./*
如果要看子目录的话 ,
grep -nr something ./*
这个在看代码的时候很有用的,特别是没有IDE的情况下
Say hello to everyday!
- keky
- 帖子: 231
- 注册时间: 2007-12-20 15:08
- 来自: harbin
- 联系:
Re: 求个shell语句
嘿嘿,更简练。。学习了..
hellojinjie 写了:LS的为什么不直接
grep -n something ./*
如果要看子目录的话 ,
grep -nr something ./*
这个在看代码的时候很有用的,特别是没有IDE的情况下