Thoughts on software and people.


Add new files to SVN

01/09/2009
I frequently find myself needing to add a bunch of new files to svn. Here's how to do it for Java files:
svn status | grep ^?.*\.java$ | awk '{print $2}' | xargs svn add
And here's how it works:
svn status |
Gets the status from Subversion and pipes it to:
grep ^?.*\.java$ |
Which matches all lines starting with a question mark (meaning they aren't in the svn repo) and ending in .java and pipes them to:
awk '{print $2}' |
Which grabs the second column of the line grep returned (the filename including path, relative to the current directory) and pipes it to:
xargs svn add
Which uses xargs to make sure the length of the command doesn't exceed the allowable limits. To get just the list of new Java files you could omit the xargs bit:
svn status | grep ^?.*\.java$ | awk '{print $2}'

comments powered by Disqus