grep -E ‘l\{2,\}‘ 2.txt
grep -E ‘h(ell|a)o‘ test.txt
grep ‘[a-z]\{5,\}‘ test.txt
grep -xf a.txt b.txt //查询a与b共同存在的行
grep -vxf b.txt a.txt //查询a的行不在b文件中面的,就是a比b多出来的行
grep -v ‘^h‘ test.txt //显示非以h开发的
grep -E ‘^(h|y)‘ test.txt //-E支持扩展正则,相当于egrep
grep -A 1 ‘hello‘ test.txt //除了显示匹配到的行也显示它之后的一行
grep -B 1 ‘hello‘ test.txt //除了显示匹配到的行也显示它之前的一行
grep -C 1 ‘hello‘ test.txt //除了显示匹配到的行也显示它之前和之后的一行
grep -r "hello" xx //在xx文件夹查找
grep -c //统计匹配的行数
grep -n //显示行号
原文:https://www.cnblogs.com/xincha/p/14950742.html