sed删除文件中的一行内容的脚本代码
更新时间:2013年03月02日 19:23:05 作者:
sed删除文件中的一行内容的脚本代码,需要的朋友可以参考下
先来看下原始文件的内容:
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
复制代码 代码如下:
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
相关文章
linux shell中 if else以及大于、小于、等于逻辑表达式介绍
在linux shell编程中,大多数情况下,可以使用测试命令来对条件进行测试,这里简单的介绍下,方便需要的朋友2013-02-02linux Shell入门:掌握Linux,OS X,Unix的Shell环境
这篇文章主要介绍了linux Shell入门:掌握Linux,OS X,Unix的Shell环境 ,需要的朋友可以参考下2015-04-04
最新评论