grep -rnw '/path/to/somewhere/' -e 'pattern' -r或者-R是递归的, -n 是行号,并且 -w 代表匹配整个单词。 -l (小写 L) 可以添加只给出匹配文件的文件名。 -e 是搜索过程中使用的模式
举报
除了这些, --exclude, --include,--exclude-dir标志可用于高效搜索:
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
grep --exclude=\*.o -rnw '/path/to/somewhere/' -e "pattern"
grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
awk "/root/" /etc/passwd
find / -type f -exec grep -l "rumenz" {} \; find . -name "*.txt" | xargs grep -i "rumenz"
本版积分规则 发表回复 回帖并转播 回帖后跳转到最后一页
等级类勋章
发帖类勋章
时间类勋章
人才类勋章
1478
12917
55
扫码关注 21ic 官方微信
扫码关注嵌入式微处理器
扫码关注电源系统设计
扫码关注21ic项目外包
扫码浏览21ic手机版
本站介绍 | 申请友情链接 | 欢迎投稿 | 隐私声明 | 广告业务 | 网站地图 | 联系我们 | 诚聘英才
京公网安备 11010802024343号