【发布时间】:2018-12-16 13:36:56
【问题描述】:
sed '/Var4/R replace.txt' input.txt | sed '/Var4/{N;s/"Var4"\n\(.*\)/"\1"/}' > "output.txt"
如果 "Var4" 位于行尾,则可以完美运行,但是如果在其后存在任何文本,则输出不正确?
输入.txt
TextBox1.Value = "Var4" Then
Else
TextBox1.Value = "- - - - - - -"
End If
TextBox1.Value = "Var4" Then
Else
TextBox1.Value = "- - - - - - -"
End If
Output.txt 应该如下所示:
TextBox1.Value = "0000AAAA" Then
Else
TextBox1.Value = "- - - - - - -"
End If
TextBox1.Value = "0000BBBB" Then
Else
TextBox1.Value = "- - - - - - -"
End If
替换.txt
0000AAAA
0000BBBB
0000CCCC
使用后的输出.txt:
sed '/Var4/R replace.txt' input.txt | sed '/Var4/{N;s/"Var4"\n\(.*\)/"\1"/}' > "output.txt"
TextBox1.Value = "Var4" Then
0000AAAA
Else
TextBox1.Value = "- - - - - - -"
End If
TextBox1.Value = "Var4" Then
0000BBBB
Else
TextBox1.Value = "- - - - - - -"
End If
有什么建议吗?
【问题讨论】:
-
抱歉不工作 >>>>>> sed '/Var4.*/R replace.txt' input.txt | sed '/Var4/{N;s/"Var4"\n(.*)/"\1"/}' > "output.txt"
标签: file variables text sed replace