当前位置:首页 / 编程技术 / 运营维护 / sed删除文件中的一行内容的脚本代码
sed删除文件中的一行内容的脚本代码
发布时间:2022/07/10来源:编程网
先来看下原始文件的内容:

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
分享到:
免责声明:本文仅代表文章作者的个人观点,与本站无关,请读者仅作参考,并自行核实相关内容。文章内容来源于网络,版权归原作者所有,如有侵权请与我们联系,我们将及时删除。
资讯推荐
热门最新
精品工具
全部评论(0)
剩余输入数量90/90
暂无任何评论,欢迎留下你的想法
你可能感兴趣的资讯
换一批