Oct 31 2005

svn add Recursively

Here is a little helpful hint if you ever wanted to add files to the svn repository recursively. I grabbed this from the TextDrive Community Forum

Add all new file to svn repository at once

svn status | grep "^?" | awk '{print $2}' | xargs svn add

You can add this to your .bash_profile as well:

svn_add_all(){
svn status | grep "^?" | awk '{print $2}' | xargs svn add
}

free b2evolution skin

1 comment

Comment from: James Wetterau [Visitor]
This has a useless use of grep and xargs.

Your use of grep and xargs replicates one of AWK's strengths as a pattern-action language. So you can save a few characters of typing and an extra process and pipe by doing it like this:

svn status | awk '/^\?/ {print $2}' | xargs svn add

But then you don't really need xargs either, you can further refine it:

svn status | awk '/^\?/ {f=f" "$2} END {system("svn add"f)}'

I believe that all of these commands suffer from the deficiency that they don't work properly on file names with spaces in them.
04/08/06 @ 09:47

This post has 11 feedbacks awaiting moderation...

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)

You can just use your OpenID to provide your name, e-mail and url.

Too Cool for Internet Explorer