shell ---6

目录

1.04101802001-04101802043正则表达式匹配

2.ipv4地址,邮箱地址,8位强密码,url正则表达式

3.sed命令使用: 地址定界和编辑命令的使用,:


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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值