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