Been having some issues with variables and sed. XMLStarlet removes the newlines from the XML which are required for openssl to read and replaces them with spaces
When executing
xmlstarlet sel -t -v '//DecryptionKey' "file.xml" | sed $"s/ /\\\r\\n/g"
the key gets formatted properly with \r\n instead of spaces
however running the exact same piece of code in the bash script nothing gets changed, same exact space containing string
XML_DecryptionKey=$(xmlstarlet sel -t -v '//DecryptionKey' "$1" | sed $"s/ /\\\r\\n/g")
I have no clue what to do, I tried it with perl, tr, awk but it just wont replace in the script.
Edit:
XML File
<?xml version="1.0"?>
<KDM>
<Metadata>
<ProjectName>U2FsdGVkX19cW2e8E2ZrzV3q18NGPmGJWCWTttOd+S4=</ProjectName>
<Encrypted>true</Encrypted>
<CustomerID>U2FsdGVkX1/SF8OjyGWfCxB3DMm6PxR/L4o6YhvcHBM=</CustomerID>
<Expires>U2FsdGVkX19HzhPXAC8tnr6P5C8Rl+4TKhMdviwrQ77v0GVhrmXDE95dq2A9PUQc
uIraONz1A4CVzlp7BbECmw==</Expires>
</Metadata>
<DecryptionKey>U2FsdGVkX19V/n561XAGZWpPSRsQ80iAtw5liYzYMfhkJ6m2XfMaOj59AmP4+H1x
4Y6n3I2WrfNEjDqoNsqkapoi+DCMDQQhwfVkj3LiuFUOIi+dzqz84xnNDzobsMb0
...
znVSKgDdLFd0EE8d3u83IlkLd+AloxfjZBjxcaLg9qOdWXFYWBr1S5/mObAJiGoO
x1K1W19T9TR48rDOLZ7zgw==</DecryptionKey>
</KDM>
Image: