I am looking to change a data file into a javascript string and this is the code that I am using:
sed -i '' -e 's/^/str += "/' -e 's/$/";/' file.xml
The first part
-e 's/^/str += "/'
works as intended, but the second part
-e 's/$/";/'
adds an additional newline to my file, so that instead of this:
str += "<?xml version="1.0" encoding="UTF-8"?><!--";
the following is the result:
str += "<?xml version="1.0" encoding="UTF-8"?><!--
";
How do I fix this?