[sed]字符串替换

 

只替换文本文件中的第一个串

sed -i '0,/oldstring/s/oldstring/newstring/' file

只替换文本文件中第一次某个串后的内容, 把第一个title后卖弄的"abcdefg"替换成"hello",原始文本如下

12445676
title abcdefg
cotent test11111
title 1234567

方法

sed '0,/title/ s/\(title \).*/\1hello/' file

 

posted @   aaronGao  阅读(359)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示