1、元字符介绍
. 匹配除换行符外的任意单个字符
* 匹配任意一个跟在它前面的字符
[] 匹配方括号中的字符类中的任意一个
^ 匹配开头
$ 匹配结尾
\ 转义后面的特殊字符
+ 匹配前面的正则表达式至少出现一次
?匹配前面的正则表达式出现零次或一次
| 匹配它前面或后面的正则表达式
-----------------------
举例说明.和$,借助文本查找工具grep
[root@harbor ~]# grep password /root/anaconda-ks.cfg
# Root password
[root@harbor ~]# grep pass... /root/anaconda-ks.cfg
auth --enableshadow --passalgo=sha512
# Root password
You have new mail in /var/spool/mail/root
[root@harbor ~]# grep pass....$ /root/anaconda-ks.cfg
# Root password
[root@harbor ~]# grep pass* /root/anaconda-ks.cfg
auth --enableshadow --passalgo=sha512
# Root password[root@harbor ~]#
[root@harbor ~]# grep ^# /root/anaconda-ks.cfg
#version=DEVEL
# System authorization information
# Use CDROM installation media
# Use graphical install
# Run the Setup Agent on first boot
# Keyboard layouts
# System language
# Network information
# Root password
# System services
# System timezon