[英]find index of word in file and replace previous characters with bash
I got a text file.我得到了一个文本文件。 It contains multiple lines, some of the has following line:
它包含多行,其中一些具有以下行:
[some random text till] this point , good to go
I need to replace [some random text]
with now from
我需要用
now from
替换[some random text]
Implementation steps:实施步骤:
1 Find index for the phrase "this point" (mandatory, need combination of two words verify this is the right line) 1 找到短语“this point”的索引(必填,需要两个词的组合验证这是正确的行)
2.Replace all previous characters with "now from" string 2.用“now from”字符串替换之前的所有字符
3.New line should be "now from this point , good to go" 3.新行应该是“现在从这一点开始,好去”
这个正在做这项工作
sed -i -e 's|${const_prrefix}.*this:'now from'|g' ${source_file}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.