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

浙公网安备 33010602011771号