Friday, May 3, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 649  / 1 Year ago, mon, march 13, 2023, 5:11:24

I have one word in one of my files and I want to substitute that word with xml file contents. considering that xml file contains some symbols which sed isn't able to process the command I am using isn't working. how can I fix this?


sed -i "s/test/$(cat header)/g" test.xml

More From » command-line

 Answers
6

Maybe:


$ var="$(printf '%q' "$(cat header)")"
$ sed -i "s,test,$var,g" test.xml

[#2173] Monday, March 13, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
strhen

Total Points: 27
Total Questions: 111
Total Answers: 103

Location: Angola
Member since Tue, Apr 25, 2023
1 Year ago
;