Introductionscript:sed -i '1i <?xml version=\1.0\ encoding=\utf-8\?>' $1sed -i '/<?xml version=\1.0\ encoding=\utf-8\?>/a<hello>\n\t<world>' $1sed -i \$a\\\t<\/hello>\n<\/world> $1input:<city id=city01>  <name>utrecht</author>  <population>328.577</population>  <districts>10</districts>  <country>netherlands</country></city>output:<?xml version=1.0 encoding=utf-8?><hello>  <world>    <city id=city01>      <name>utrecht</author>      <population>328.577</population>      <districts>10</districts>      <country>netherlands</country>    </city>  </hello></world>QuestionWhat are more concise methods for wrapping a file than using sed?
More concise methods for wrapping a file than using sed
text processing;sed
As I said in my comment, I don't understand what your actual question is. Here are some more concise ways of doing what your sed script does:$ printf %s\n%s\n\t%s\n%s\n%s\n%s\n '<?xml version=1.0 encoding=utf-8?>' \'<hello>' '<world>' $(cat file) </world> </hello><?xml version=1.0 encoding=utf-8?><hello>    <world><city id=city01>  <name>utrecht</author>  <population>328.577</population>  <districts>10</districts>  <country>netherlands</country></city></world></hello>or$ echo -e '<?xml version=1.0 encoding=utf-8?>' \n<hello>\n<world> $(cat file) \</world>\n</hello><?xml version=1.0 encoding=utf-8?> <hello><world> <city id=city01>  <name>utrecht</author>  <population>328.577</population>  <districts>10</districts>  <country>netherlands</country></city> </world></hello>or$ perl -lpe 'BEGIN{            print <?xml version=\1.0\ encoding=\utf-8\?>\n<hello>\n\t<world>            }             $_=\t\t$_; END{print \t </world>\n</hello>}' file<?xml version=1.0 encoding=utf-8?><hello>    <world>        <city id=city01>          <name>utrecht</author>          <population>328.577</population>          <districts>10</districts>          <country>netherlands</country>        </city>     </world></hello>You can edit the file in place with perl -i -ple.or$ awk 'BEGIN{printf <?xml version=\1.0\ encoding=\utf-8\?>\n<hello>\n\t<world>;}         {print \t\t,$0}END{printf \t </world>\n</hello>\n}' file<?xml version=1.0 encoding=utf-8?><hello>    <world>      <city id=city01>           <name>utrecht</author>           <population>328.577</population>           <districts>10</districts>           <country>netherlands</country>         </city>     </world></hello>or a mixture:$ echo -e '<?xml version=1.0 encoding=utf-8?>\n<hello>\n\t<world>';   perl -pe '$_=\t\t$_' file; echo -e </world>\n</hello><?xml version=1.0 encoding=utf-8?><hello>    <world>        <city id=city01>          <name>utrecht</author>          <population>328.577</population>          <districts>10</districts>          <country>netherlands</country>        </city></world></hello>