sed在指定的行末尾添加指定的字符和删除指定的字符

[root@centos7 data]# cat func1.sh
#!/bin/bash
get_os() {
cat /etc/os-release
uname -r
echo "hello world"
}

get_os

 

例1:在第3至第5行末尾添加;

[root@centos7 data]# sed -i '3,5 s/$/;/' func1.sh

例2:删除第3行到第5行末尾的;

[root@centos7 data]# sed -i '3,5 s/;//' func1.sh

 

posted @ 2021-08-04 16:59  Real_Raul  阅读(965)  评论(0)    收藏  举报