手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >sed删除文件中的一行内容的脚本代码
sed删除文件中的一行内容的脚本代码
摘要:先来看下原始文件的内容:复制代码代码如下:root@localhost~]#catfile.txthelloworlda:b:c-h-na:...

先来看下原始文件的内容:

复制代码 代码如下:

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删除文件中的一行内容的脚本代码】相关文章:

ssh expect自动登录的脚本代码

备份shell脚本实例代码

判断文件是否存在的shell脚本代码

统计网卡流量的两段shell脚本(使用ifconfig)

Shell实现的Oracle启动脚本分享

VPS自动备份数据库到FTP的脚本代码

Linux Shell中判断进程是否存在的代码

五个常用的Linux监控脚本代码

备份网站内容的shell脚本代码

提取oralce当天的alert log的shell脚本代码

精品推荐
分类导航