hello,
trying make bash script add "template-like" structure new xml file
i have bash script add 3 line template settings.xmlcode:settings.xml <?xml version='1.0'?><map> </map>
the problem above code outputs literal variable new_settingscode:newclass='''<object file="new" > \n <string>new</string> \n </object>' # insert blank class sed '1a\ $newclass' settings.xml > new_settings.xml
if try double quotes around sed argument, errorcode:new_settings.xml <?xml version='1.0'?><map> $newclass </map>
anyone able explain how make work?code:sed: -e expression #1, char 29: unknown command: `<'
the quoting confusing me, seems work:
why have 3 single quotes @ beginning, way? first 2 result in empty string, can removed.code:newclass='''<object file="new" >\\ <string>new</string>\\ </object>' tmpfile=/tmp/sed$$ echo "1a\\" >$tmpfile echo "$newclass" >>$tmpfile # insert blank class sed -f $tmpfile settings.xml > new_settings.xml rm -f $tmpfile
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Bash and Sed with Variable
Ubuntu
Comments
Post a Comment