Adding unversioned files from Linux command line

Add all unversioned files from the command line using regular expressions.

svn status | grep '^?' | cut -c9- | sed -rn 's/^(.*)$/\"\1\"/p' | xargs svn add

svn status | grep '^?'
lists only un-versioned files.

cut -c9-
grabs only filename and path by cutting up to the 9th column removing the ? symbol and whitespace

sed -rn 's/^(.*)$/\"\1\"/p'
surrounds the filename with “double quotes” in case there are any spaces or your command prompt has an issue with the slashes being used in the path.

xargs svn add
executes svn add for each file.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s