4

HI all,

Is there a linux command which will output the structure of a given directory as XML? if there is, that would be awesome.

Thanks very much

2
  • That sounds like it wouldnt be too tough to implement upstream, you should consider adding an extension to the tree command or ask the maintainer to do it for you: mama.indstate.edu/users/ice/tree might not be a solution for right now but it may help someone else down the line. If you don't write it I will, cus its a good idea! May 12, 2010 at 11:33
  • Hi Andrew, Yes, this exactly what i've been thinking. I looked at the 'tree' command before I posted the question. I was surprised there was not an option on the command like tree /tmp --xml or something similar. Alas, i'm not too familiar with C (i presume it's written in that) so I would struggle to write it but by all means if you can (and of course if you have the time to do so) then that would be AWESOME. Thanks.
    – Jamie
    May 12, 2010 at 16:07

4 Answers 4

0

XMLStarlet will do this.

xml ls
1
  • Installation: sudo apt install xmlstarlet, usage: xmlstarlet ls
    – Pablo A
    Aug 25, 2023 at 22:17
8

You can do this by using 'tree' command.

tree -X <dir>
1
  • tree --help for all options (HTML output, etc)
    – Abram
    Dec 11, 2015 at 15:22
0

As far as I know there is no standard linux command to do the job, but google-ing I found that there is a free multi platform: xml-directory-listing

Unfortunately it is written in Java.

1
  • Hi Albert, Thanks. I will give it a go and report my findings :-)
    – Jamie
    May 12, 2010 at 7:54
0

You could easily write a script for that, using languages such as Perl, Python or Ruby should do well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .