1

I am trying a sed replacement from a text file and whats in the text file has a & character in different parts of whats in the text file so it just appends it. I want to replace and not append. I am doing this with multiple vars and the & is in different spots on each var and sometimes back to back & characters inthe middle of the string.

echo $myvar > temp.txt
sed -i "s/orignaltxt/$(cat temp.txt)/" file.yaml
Tom Donnly
  • 19
  • 5
  • `s/originaltxt/cat temp.txt/e` will work to do exactly what you want here. `s///e` takes whatever is on the replacement side and calls the shell to obtain the replacement string, and it can include ampersand. `/originaltext/r temp.txt` is similar but will append rather than replace. – stevesliva Oct 29 '21 at 18:40

0 Answers0