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

Jamie
  • 213
  • 3
  • 6
  • 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: http://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! – Andrew Bolster May 12 '10 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 '10 at 16:07

4 Answers4

8

You can do this by using 'tree' command.

tree -X <dir>
user177405
  • 81
  • 1
  • 2
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.

drAlberT
  • 10,949
  • 7
  • 39
  • 52
0

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

raphink
  • 11,987
  • 6
  • 37
  • 48
0

XMLStarlet will do this.

xml ls
Pablo A
  • 177
  • 1
  • 9
mfinni
  • 36,144
  • 4
  • 53
  • 86