sed '/Var4/R replace.txt' input.txt | sed '/Var4/{N;s/"Var4"\n\(.*\)/"\1"/}' > "output.txt"
Works perfectly if "Var4" is at the end of the line, however if any text exists after it, the output is incorrect ?
Input.txt
TextBox1.Value = "Var4" Then
Else
TextBox1.Value = "- - - - - - -"
End If
TextBox1.Value = "Var4" Then
Else
TextBox1.Value = "- - - - - - -"
End If
Output.txt should look like this:
TextBox1.Value = "0000AAAA" Then
Else
TextBox1.Value = "- - - - - - -"
End If
TextBox1.Value = "0000BBBB" Then
Else
TextBox1.Value = "- - - - - - -"
End If
Replace.txt
0000AAAA
0000BBBB
0000CCCC
Output.txt after using:
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
Any Advice ?