shell每日一句(3)

5月28号 晚上8点:

文件格式如下:

123abc456
456def123
567abc789
789def567
要求输出:
456ABC123
123DEF456
789ABC567
567DEF789

初看上去知道这里需要用到大小写字母转化,还有数字位置转换等:

[root@fsailing1 shell]# sed 'y/abcdef/ABCDEF/' chen1.txt 123ABC456 456DEF123 567ABC789 789DEF567 [root@fsailing1 shell]# sed -r 's/([1-9]{3})([a-f]{3})([1-9]{3})/\3\2\1/g' chen1.txt 456abc123 123def456 789abc567 567def789 结合起来就是:

[root@fsailing1 shell]# sed -r 's/([1-9]{3})([a-f]{3})([1-9]{3})/\3\2\1/g;y/abcdef/ABCDEF/' chen1.txt 456ABC123 123DEF456 789ABC567 567DEF789

5月29号 下午4点

[root@fsailing1 shell]# sed 's/a/f/' chen.txt f a a a a fa b b b b b bb c c c c c cc d d d d d dd [root@fsailing1 shell]# sed 's/a/f/g' chen.txt f f f f f ff b b b b b bb c c c c c cc d d d d d dd

5月30号下午2点:

文档的格式:

aa:bb

cc:dd

转变成:

bb:aa

dd:cc

[root@fsailing1 shell]# sed 's/\(.*\):\(.*\)/\2:\1/' chen1.txt 其中:这里反斜杠的意义在于转义字符。 bb:aa dd:cc ff:ee ii:hh

5月31号下午4点:

册除空行和带#号的这一行:

在正则表达式中“.”表示任意一个字符,“*”表示任意多个前面的字符。

我们知道以什么字符开头的正则表达式是“^”开头的,那么空行就是“^$”表示以空开头以空结尾。

sed '/^$/d' /etc/vsftpd/vsftpd.conf 还有带有#号的也要删除,

sed '/\#.*/d' /etc/vsftpd/vsftpd.conf [root@fsailing1 /]# sed -e '/^$/d' -e '/\#.*/d' /etc/vsftpd/vsftpd.conf anonymous_enable=YES local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES listen=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值