Variable XFILEBASE64 has base64 encoded content and I want to replace some string with that base64 content.
Sure enough base64 is packed with special characters, and I've tried $'\001' as delimiter, still getting the error message. Any suggestions?
XFILEBASE64=`cat ./sample.xml | base64`
cat ./template.xml | sed "s$'\001'<Doc>###%DOCDATA%###<\/Doc>$'\001'<Doc>${XFILEBASE64}<\/Doc>$'\001'g"
> sed: -e expression #1, char 256: unterminated `s' command
EDIT: Looks like problem has nothing to do with sed, it must be hidden in base64 operations.
sample.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<a>testsdfasdfasdfasfasdfdasfdads</a>
To reproduce the problem:
foo=`base64 ./sample.xml`
echo $foo | base64 --decode
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<base64: invalid input
The problem was in base64 encoding, -w 0 option of base64 did the trick.
cat ./sample.xml | base64 -w 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With