Jarkko(_dot_)Moilanen(_at_)uta(_dot_)fi wrote:
So there is no root level element, how do I add it there?
Most every shell uses '>' to redirect (creating/overwriting the destination),
and '>>' to append (raising an error if the destination does not exist).
Some shells have a 'noclobber' option that controls whether or not '>' will
overwrite an existing file or raise an error. How you set this option depends
on what shell you're using. #!/bin/sh implies Bourne shell, but on some Linux
systems they've replaced it with Bourne Again shell (bash), which was not a
good idea, in my opinion. 'man sh' or 'man bash' will give you all the
details. Anyway...
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' > list.xml
echo '<LangList>' >> list.xml
ls lang_*.xml | sed -e "s(_at_)\(.*xml\)@<language>\1</language>@" >> list.xml
echo '</LangList>' >> list.xml
Instead of 'ls', you might want to do '/bin/ls -1'. Many people create
personal aliases for 'ls' that change the list format. By explicitly
specifying /bin/ls, you avoid using the alias. The -1 forces the output to be
one filename per line, in case the default on your system is multicolumn.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list