目录
1.04101802001-04101802043正则表达式匹配
1.04101802001-04101802043正则表达式匹配
[root@shell ~]# echo "04101802001" | egrep "^041018020(0[1-9]|[1-3][0-9]|4[0-3])$"
04101802001
[root@shell ~]# echo "04101802043" | egrep "^041018020(0[1-9]|[1-3][0-9]|4[0-3])$"
04101802043
[root@shell ~]# echo "04101802022" | egrep "^041018020(0[1-9]|[1-3][0-9]|4[0-3])$"
04101802022
2.ipv4地址,邮箱地址,8位强密码,url正则表达式
[root@shell ~]# echo "123456789@qq.com" | egrep "^([1-9]*[1-9][0-9]*)@qq.com$"
123456789@qq.com
3.sed命令使用: 地址定界和编辑命令的使用,:
[root@shell test]# cat tt.txt
12
34
56
78
90
#: d命令(删除)
[root@shell test]# sed '/12/d' tt.txt
34
56
78
90
i \text命令
[root@shell test]# sed '3 i\qw' tt.txt
12
34
qw
56
78
90
c \text命令
[root@shell test]# sed '3 c\qw' tt.txt
12
34
qw
78
90
#,#: p命令
[root@shell test]# sed -n '1,$p' tt.txt
12
34
56
78
90
#~#: s/pattern/string
[root@localhost ~]# sed 's/^[[:space:]]//' grub2.cfg
#,+N: s/pattern/string/g
[root@localhost ~]# sed 's/[^0-9a-zA-Z]//g' test.txt
#,~N: d命令
[root@shell test]# sed -i '2,$d' tt.txt
[root@shell test]# cat tt.txt
12
$:d命令
[root@shell test]# sed -e '2,$d' tt.txt
12
[root@shell test]# cat tt.txt
12
34
56
78
90