Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1695814
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类:

2009-10-29 16:02:54

#!bin/sh
# first.sh
# This file looks through all the files in the current directory for the string POSIX,
# and then dispaly those files to the stand output

for file in *
do
if grep -o POSIX $file
then
more $file
fi
done
 
exit 0


还有其他方法:利用find 和 grep
查找 包含alias字符串的*.conf的文件

find / -name "*.conf" | xargs grep "alias"

1. grep -R -l 一些也可以实现,但是通过管道 | 比单纯用grep 复杂的参数更有效率。
2. xargs是用来展开find获得的结果,使其作为grep的参数。
阅读(818) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~