标签:空行 div input bsp amp bbb lin inpu 指定
要求:在1111之前添加AAA,命令如下:
sed -i ‘s/指定的字符/要插入的字符&/‘ 文件
[root@localhost ~]# sed -i ‘s/1111/AAA&/‘ /tmp/input.txt
[root@localhost ~]# cat /tmp/input.txt null0000AAA11112222
要求:在1111之后添加BBB,命令如下:
sed -i ‘s/指定的字符/&要插入的字符/‘ 文件
[root@localhost ~]# sed -i ‘s/1111/&BBB/‘ /tmp/input.txt
[root@localhost ~]# cat /tmp/input.txt null0000AAA1111BBB2222[root@localhost ~]# sed ‘/^$/d‘ /tmp/input.txt
null0000BBB1111AAA2222[root@localhost ~]# sed ‘s/1111/AAA&/;s/1111/&BBB/‘ /tmp/input.txt
null0000BBB1111AAA2222test[root@localhost ~]# sed -i ‘s/^/HEAD&/‘ /tmp/input.txt
[root@localhost ~]# cat /tmp/input.txtHEADnullHEAD000011112222HEADHEADtest[root@localhost ~]# sed -i ‘s/$/&tail/‘ /tmp/input.txt
[root@localhost ~]# cat /tmp/input.txt HEADnulltailHEAD000011112222tailHEADtailHEADtesttail
标签:空行 div input bsp amp bbb lin inpu 指定
原文地址:https://www.cnblogs.com/lyongyong/p/12408597.html