您的位置:首页 > 其它

grep

2015-10-16 20:24 197 查看
grep "--color=auto" 搜索内容 filename

-i 区分大小写

-n 显示行号

-c 计算次数

-v 排除

-A(number) 后几行

-B(number) 前几行

c4:~# cat test
test1
test2
test3
test4
c4:~# grep -A1 test2 test
test2
test3
c4:~# grep -B1 test2 test
test1
test2
c4:~# grep -1 test2 test
test1
test2
test3

-E

egrep 'A|B' testfile
grep -E 'A|B' testfile

-o only-matching

-o与-E结合:

c4:~# cat test
test1
test2
test3
test4
c4:~# cat test |grep -o -E e
e
e
e
e
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: