您的位置:首页 > 其它

用sed命令在文本中插入一行

2013-10-10 17:04 260 查看
1.sed -i "/feibao/a\yibin" 1.text

先查找字符串feibao,a\的意思是在找到feibao字符串之后一行插入后面的字符串yibin

后面接文件名

2.sed -i "2 yibin" 1.text

在第二行后面插入一行yibin,2表示第二行

3.s/re/string :用string替换正则表达式re。

sed "s/persist.sys.country=CN/persist.sys.country=TH/" ${OUT}/system/build.prop

替换build.prop里的默认国家

4.sed "s/feibao/yibin/" 1.txt | \

sed "s/yibin/tihuan/" | \

sed "s/tihuan/yes/" | \

sed "/yes/a\whyno" | \ or "/yes/i\whyno"(之前与之后一行)

sed "s/yes/no/" > 2.txt

最后结果为:no

whyno

具体参照网址:http://www.2cto.com/os/201109/102812.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: