Results 1 to 10 of 11
I'm wanting to be able to write a text file with a list of all the files that have been updated since the last svn update with each file on ...
- 02-11-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 4
Formatting svn status output
I'm wanting to be able to write a text file with a list of all the files that have been updated since the last svn update with each file on a separate line.
To do this I need to format the output of this:
into thisroot@server # svn status -u
* 9 admin.php
* 9 index.php
* 9 functions/myfuncs.php
N 9 functions/newfile.php
Status against revision: 10
I am really inexperienced in the voodoo of regex but I suspect thats what is needed here. Anyone care to share their wisdom with this noob?root@server # svn status -u
admin.php
index.php
functions/myfuncs.php
functions/newfile.php
Thanks
- 02-11-2008 #2
You don't need a regular expression at all. Instead, you can use the cut utility.
Basically, you tell cut what character separates your columns (in this instance, a space), and what columns you want (in this case, the third), and it will only give you those columns back.
Check the man page for more info.DISTRO=Arch
Registered Linux User #388732
- 02-11-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 4
Sorry I shouldn't have used quote tags there
There is more than one space between those columns. I don't think theyre tab characters either. Would cut still work?Code:root@server # svn status -u * 9 admin.php * 9 index.php * 9 functions/myfuncs.php N 9 functions/newfile.php Status against revision: 10
- 02-11-2008 #4
Ah, right you are sir. Easy enough! We will resort to sed and regular expressions, then.
Basically, we want to remove everything except for the last column:
Why does this work? I have told sed to replace 1 or more of any character, followed by a space, with nothing. Most regular expressions are "greedy", which means that they try and match as much as they possibly can. Therefore, that last space comes as late as possible, and it catches on the space just before the last column, so everything up to and including that is removed.Code:alex@danu ~/test/bash $ cat svn_output * 9 admin.php * 9 index.php * 9 functions/myfuncs.php N 9 functions/newfile.php alex@danu ~/test/bash $ sed -e 's/.\+ //' svn_output admin.php index.php functions/myfuncs.php functions/newfile.php
Make sense?DISTRO=Arch
Registered Linux User #388732
- 02-12-2008 #5Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Or simply with awk, print field 3 if the line doesn't begin with Status:
RegardsCode:awk '!/^Status/{print $3}' svn_output
- 02-12-2008 #6Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
- 02-12-2008 #7Just Joined!
- Join Date
- Feb 2008
- Posts
- 4
Indeed he did which leads to a trailing integer at the end of the file and Franklin yours didn't work perfectly either but thats my fault as again the status output was wrong :S
install.php is a new file. I thought it displayed N instead of a * and the version number but apparently not. Sorry.Code:* install.php * 9 admin.php * 9 . Status against revision: 11
This is good stuff though I'm learning some tricks I didn't know. I appreciate it
- 02-12-2008 #8Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Did you solve the problem? If not post the exact svn output and the desired output.
Regards
- 02-13-2008 #9
Sorry for forgetting that last line. In any event, I think that my approach is more easily adaptable:
My sed expression says that for any line that starts with "Status", ignore it. Otherwise, delete everything up through the last space.Code:alex@danu ~/test/bash $ cat svn_output * install.php * 9 admin.php * 9 . Status against revision: 11 alex@danu ~/test/bash $ sed -e '/^Status/ d; /^Status/ ! s/.* //' svn_output install.php admin.php .
Note that my approach will _not_ work if any of the filenames have a space in them.DISTRO=Arch
Registered Linux User #388732
- 02-13-2008 #10Linux User
- Join Date
- Aug 2006
- Posts
- 458
if you look at the help of svn, using
you can see :Code:svn help status
you could possible try to substring from nineth character onwards.The out-of-date information appears in the eighth column (with -u):
'*' a newer revision exists on the server
' ' the working copy is up to date


Reply With Quote
