网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

grep常见选项及命令

-E 按Extended规范进行匹配

我们提供的服务有:成都做网站、成都网站建设、微信公众号开发、网站优化、网站认证、仁寿ssl等。为成百上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的仁寿网站制作公司

--color 标记匹配颜色

-i 忽略大小写匹配

[fbl@www test6_26]$ echo "hello" | grep -i --color 'HELLO'
hello

-q 安静匹配 即不输出内容

[fbl@www test6_26]$ echo "hello" | grep -q --color 'hello'
[fbl@www test6_26]$ echo $?
0

-o 只输出匹配到的部分

[fbl@www test6_26]$ echo "hello" | grep -E -o --color 'hell*'
hell

-w 只显示全字符合的lie

[fbl@www test6_26]$ cat file1
hello
helloo
hell
[fbl@www test6_26]$ cat file1 | grep -E --color 'hell'
hello
helloo
hell
[fbl@www test6_26]$ cat file1 | grep -wE --color 'hell'
hell

[fbl@www test6_26]$ cat file

apple

bahyude

nue

111123

88888

hello

change

brance

6666

[fbl@www test6_26]$ cat file | grep -E --color '^[a-z]{1,}[a-z]$'
apple
bahyude
nue
hello
change
brance

-c 输出匹配到的列数

[fbl@www test6_26]$ cat file | grep -cE --color '^[a-z]{1,}[a-z]$'
6

-n 显示匹配到的列及列号

[fbl@www test6_26]$ cat file | grep -nE --color '^[a-z]{1,}[a-z]$'
1:apple
2:bahyude
3:nue
6:hello
7:change
8:brance

-v 显示不匹配的列

[fbl@www test6_26]$ cat file | grep -vE --color '^[a-z]{1,}[a-z]$'
111123
88888
6666

-a 偏移匹配

[fbl@www test6_26]$ cat file | grep -a2 --color 'hello'
111123
88888
hello
change
brance

当前标题:grep常见选项及命令
本文路径:http://bjjierui.cn/article/pedoco.html

其他资讯