I am trying to sort my XML file that looks like this by alphabetical order. This is a part of a larger bash script so it needs to work within that script:
<Module>
<Settings>
<Dimensions>
<Volume>13000</Volume>
<Width>5000</Width>
<Length>2000</Length>
</Dimensions>
<Stats>
<Mean>1.0</Mean>
<Max>3000</Max>
<Median>250</Median>
</Stats>
</Settings>
<Debug>
<Errors>
<Strike>0</Strike>
<Wag>1</Wag>
<MagicMan>0</MagicMan>
</Errors>
</Debug>
</Module>
I want the end result to look like this, I only want the innermost tags to be sorted:
<Module>
<Settings>
<Dimensions>
<Length>2000</Length>
<Volume>13000</Volume>
<Width>5000</Width>
</Dimensions>
<Stats>
<Max>3000</Max>
<Mean>1.0</Mean>
<Median>250</Median>
</Stats>
</Settings>
<Debug>
<Errors>
<MagicMan>0</MagicMan>
<Strike>0</Strike>
<Wag>1</Wag>
</Errors>
</Debug>
</Module>
I am trying to use sort like this where -t sorts by the > delimeter and then the 4 sorts by the 4th column which would be in the inner but it is not working.
sort -t'>' -k4 file > final.xml
I get funky output that sorts the other columns in with the sorted inner tags.
Any help would be appreciated
awk --versionoutput)?