I'm trying to use the following code to update a file within a kubernetes pod/container
I'm setting some variables;
searchline='<Logger name="com.mycompany" level="INFO" additivity="false">'
newline='<Logger name="com.mycompany" level="DEBUG" additivity="false">'
then using the following command;
kubectl exec mypod -- bash -c "cp conf/log4j2.xml conf/log4j2.xml.bkup && sed -i "s/$searchline/$newline/g" conf/log4j2.xml"
sed: -e expression #1, char 8: unterminated `s' command
However, if I shell into the pod and manually run the same sed command
sed "s/$searchline/$newline/g" conf/log4j2.xml
(not in the bash -c "" format) it runs as it should.
Not sure why it doesn't work within the bash -c, probably has something to do with the double quotes in the bash -c command..
any help would be appreciated.