tags:

views:

406

answers:

3

I have this snippet i found.

svn status | grep '\!' | awk '{print $2;}' | xargs svn rm

It removes all missing files, if I or someone deletes the files manually (via the editor or they are deleted via the system)

But my bash coding is not great, what it's missing is that it does not work with files that have spaces in it.

svn rm Super\ Test.file

Is the correct way to remove files with a space, but I don't know how to modify the snippet above so it works. (or if you have another snippet that does)

+4  A: 
svn status | grep '^\!' | cut -c8- | while read f; do svn rm "$f"; done
cadrian
Works, thanks :)
Ólafur Waage
+3  A: 

You could 0 escape and use the -0 flag to xargs.

svn st | awk '/^!/ { sub("^! +", ""); printf "%s\0", $0 }' | xargs -0 svn rm

This has another advantage in that files with quotes or other special characters will not screw up the xargs command line either.

rq
A: 

With GNU awk, I can do:

svn stat | awk -v FIELDWIDTHS="1 6 1000 1" -v ORS=$'\0' '$1 == "!" { print $3 }' | xargs -0 svn rm
Bruno De Fraine