首页 > 系统服务 > 详细

Linux 之 正则表达式实例

时间:2018-05-08 20:07:30      阅读:196      评论:0      收藏:0      [点我收藏+]
正则表达式实例
文件内容:
I am oldboy teacher!
I teach linux.
Ilike badminto ball http:/www.baidu.com
my qq num is 412421412

I am oldboy teacher!
I teach linux.

I like badminton ball,billiard ball and chinese chess!
my blog is http://oldboy.blog.51cto.com
our site is http://www.etiantian.org
my qq num is 444877

not 44453434
my god,i am not oldbey,but OLDBOY!

1.基础正则第一学
^word      匹配以word开头的内容。
word$      匹配word结尾的内容。
^$            表示空行

示例:
[root@localhost kang]# grep "^m" test.txt  #以m开头
my blog is http://oldboy.blog.51cto.com
my qq num is 444877
my god,i am not oldbey,but OLDBOY!

[root@localhost kang]# grep "m$" test.txt   #以m结尾
my blog is http://oldboy.blog.51cto.com

[root@localhost kang]# grep "^$" test.txt      #输出空行

[root@localhost kang]# grep -v "^$" test.txt     #排除空行

Linux 之 正则表达式实例

原文:http://blog.51cto.com/12965094/2114148

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!