标签:正则表达式
正则表达式实例文件内容:
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 #排除空行
标签:正则表达式
原文地址:http://blog.51cto.com/12965094/2114148