先来看下原始文件的内容:
复制代码 代码如下:
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删除文件中的一行内容的脚本代码的全部内容,更多相关sed删除文件中内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复