> grep ^[^#] rumenz.txt
> grep ^# rumenz.txt
> grep "rumenz" 1.txt
> grep "rumenz" *.html
> grep -in "rumenz" 1.txt
> grep -c "rumenz" 1.txt
> grep -l "rumenz" *
-l: 查询多文件的时候只输出包含匹配字符的文件名
> grep -rl "rumenz" .
不会输出任何信息,如果命令运行成功返回0,失败则返回非0值。一般用于条件测试。
> grep -q "rumenz" 1.txt
> grep -R --exclude-dir="tmp" "rumenz"
tmp 中的文件不用查找
> cat 1.txt | grep -v "^\s*$"
> cat 1.txt | grep -v "^#"
> cat 1.txt | grep -v "^$" | grep -v "^#"
> grep -A 5 'rumenz' 1.txt
> grep -B 5 'rumenz' 1.txt
> grep -C 5 'rumenz' 1.txt
> grep "abc" 1.txt //结果为abcd, abcde, abc等
> grep -w "abc" 1.txt
> cat 1.txt | grep -e "ab" -e "ef" -o
> grep -r "rumenz" --include *.{html,php}
> grep -r "rumenz" --exclude "README" .
> cat filelist
aaa
bbb
rumenz
> grep -r "rumenz" --exclude-from filelist .
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。