LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 656|回复: 1

shell中,怎么处理这样的

[复制链接]
发表于 2006-10-31 21:29:07 | 显示全部楼层 |阅读模式
:~# find /usr/include/ -name stdlib.h -print
/usr/include/stdlib.h
find的输出如上,我想在/usr/include/stdlib.h中查找"EXIT_FAILURE"

如果
find /usr/include/ -name stdlib.h -print|grep  "EXIT_FAILURE" -

是去查找“/usr/include/stdlib.h“这个字符串,而不是/usr/include/stdlib.h这个文件里面的内容


怎么解决:confused:
发表于 2006-10-31 22:58:21 | 显示全部楼层
  1. [0 No.1283 huan@huan ~/tmp]$ cat test
  2. def
  3. abc
  4. [0 No.1284 huan@huan ~/tmp]$ find . -name 'test' | xargs grep 'abc'
  5. abc
  6. [0 No.1285 huan@huan ~/tmp]$
复制代码
  1. [0 No.1285 huan@huan ~/tmp]$ for f in $( find . -name 'test' ); do grep 'abc' $f; done
  2. abc
  3. [0 No.1286 huan@huan ~/tmp]$
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表