Extracting SVN info from cli (command line)

For one of my project, I needed to have the SVN Repo URL for one of the file.

When doing svn info, this returns the URL in a readable format. I wanted a format that less likely to change over time (when I upgrade svn for example).

Without being set in stone, I think that an XML version of this information will less likely change! (Maybe I am wrong).

HURRAY, svn supports this!

$ svn info --xml

<?xml version="1.0"?>

I was building a shell script, so I added to be able to parse XML from the command line.

I found : XMLStarlet

Ubuntu installation:

$ sudo apt-get install xmlstarlet

CentOS Installation:

  1. http://sourceforge.net/projects/xmlstar/files/
  2. http://www.dil.univ-mrs.fr/linux/dil/centos/5/

Here is an example on how to use it:

$ svn info path/to/file --xml | xmlstarlet sel -t -v 'info/entry/url'

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options