代码改变世界

用find & grep查找文件内容

2011-04-22 10:18  白居不易  阅读(215)  评论(0编辑  收藏  举报

查找 包含alias字符串的*.conf的文件

find / -name “*.conf” | xargs grep “alias”

1. grep -R -l 一些也可以实现,但是通过管道 | 比单纯用grep 复杂的参数更有效率。
2. xargs是用来展开find获得的结果,使其作为grep的参数。