Pipe shell output to svn del?

I have a rather complicated deployment setup for our Drupal site, which is a combination of CVS and SVN. We use CVS to get the latest versions of modules and deploy using SVN. Unfortunately, when CVS updates delete files, Subversions complains because they were not deleted in SVN. I am trying to execute some shell and Perl scripts to run the svn rm for all of these files that have already been deleted from the file system, but I did not get far. What I'm still like this:

 svn st | grep ! 

A list of all files deleted from the file system is displayed here:

 ! panels_views/panels_views.info ! panels_views/panels_views.admin.inc ! contexts/term.inc ! contexts/vocabulary.inc ! contexts/terms.inc ! contexts/node_edit_form.inc ! contexts/user.inc ! contexts/node_add_form.inc ! contexts/node.inc etc. . . 

However, I want to somehow run svn del on each of these lines. How can I get this output in my Perl script, or, alternatively, how can I run svn del on each of these lines?

Edit: The exact command I used with some help from everyone was

 svn st | grep ^! | cut -c 9- | xargs svn del 
+7
shell svn
source share
3 answers

Try using xargs , for example:

 svn st | grep ^! | cut -f2 | xargs svn rm 

The xargs command takes lines on its standard input and rotates them and uses these lines as command line parameters on svn rm . By default, xargs uses several lines with each invocation of its command, which is svm rm with svm rm .

You may also need to experiment with the cut command to get it in order. By default, cut uses a tab as a delimiter, and Subversion can output spaces there. In this case, you may have to use cut -d' ' -f6 or something else.

As always, when building such a command pipeline, run the chunks at a time to make sure everything looks right. Therefore, run everything before the cut to make sure you have a list of file names that you expect before starting it again with "| xargs svn rm" at the end.

+10
source share
 svn st | egrep ^! | cut -b 9- | xargs svn del 
+1
source share

As an alternative to the above, I would use something like:

 svn st | awk '$1=="!"{print $2}' | xargs svn del 

I find the awk language matching pattern very convenient for such tasks.

0
source share

All Articles