您现在的位置是:网站首页> 编程资料编程资料
sed删除文件中的一行内容的脚本代码_linux shell_
2023-05-26
369人已围观
简介 sed删除文件中的一行内容的脚本代码_linux shell_
先来看下原始文件的内容:
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
相关内容
- bash scp command not found的解决方法_linux shell_
- linux中mysql备份shell脚本代码_linux shell_
- linux下使用perl获取本机ip的几种方法介绍_linux shell_
- Linux下使用Shell脚本实现ftp的自动上传下载的代码小结_linux shell_
- 神奇的shell命令行输入与输出功能介绍_linux shell_
- 获取两个日期间隔时间的shell脚本代码_linux shell_
- linux shell中 if else以及大于、小于、等于逻辑表达式介绍_linux shell_
- 判断文件是否存在的shell脚本代码_linux shell_
- 用shell命令读取与输出数据的代码_linux shell_
- linux shell命令执行顺序的控制方法_linux shell_
