Last Updated: February 25, 2016
·
494
· brendanjcaffrey

Bash: run 'svn rm' on all deleted files

When you use rm to delete a bunch of files in a subversion repo, and you run svn status, you get a bunch of lines like this:

!       path/to/file.cc
!       path/to/file.cc
!       path/to/file.cc

If you try to commit in this state, the deletions won't actually go through - you have to run svn rm on all those files. But why do it manually for each file? Just use this:

svn status | grep ! | awk '{print $2}' | while read line ; do svn rm $line; done

When you run just svn status | grep ! | awk '{print $2}', you get a list of all file names that have been deleted from disk but not removed from the repo. The last part just iterates over all the files and runs svn rm on them.