正则表达式实战举例(续):
3).*:任意字符
[root@test2 tmp]# cat test2.txt
lovely
livl
levllaeq
lcveroop
woeijfdklkiod
love mo forerver
hahahh lilylilei
ku hou haha xixi
zxysypr
love mo forervez
[root@test2 tmp]# grep ".*" test2.txt
lovely
livl
levllaeq
lcveroop
woeijfdklkiod
love mo forerver
hahahh lilylilei
ku hou haha xixi
zxysypr
love mo forervez
4)[ ]:匹配一组字符中的任意一个
[0-9]
[a-z]
[A-Z]
[a-Z]
[a-Z0-9]
[^0-9]
[^a-Z]
[^...]
[root@test2 tmp]# grep "[a-z][a-z][a-z][A-Z]" passwd --color
rooT:x:0:0:root:/root:/bin/bash
[root@test2 tmp]# grep "^[a-z][a-z][a-z]:" passwd --color
bin:x:1:1:bin:/bin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
5)\ :转义字符,屏蔽元字符的含义。
[root@test2 tmp]# cat 2.txt
abc
acd
djjoediofjf
diijew9f9e90
a.c
[root@test2 tmp]# grep "a.c" 2.txt
abc
a.c
[root@test2 tmp]# grep "a\.c" 2.txt
a.c
未完待续。。。。。。