先来看下原始文件的内容:
实现代码如下:

root@localhost ~]# cat file.txt
hello world
a:b:c -h -n
a:b:c -h -n

sed根据条件删除相关的行:
实现代码如下:

[root@localhost ~]# sed -i '/a:b:c -h -n/d' file.txt
[root@localhost ~]# cat file.txt
hello world

sed根据条件进行相关内容的替换:
实现代码如下:

[root@localhost ~]# sed -i 's/hello/baidu/' file.sh
[root@localhost ~]# cat file.sh
baidu world

以上就是【sed删除文件中的一行内容的脚本代码】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论