When using Subversion for version control, if you have a working copy checked out and then you want to add a variety of new files and directories to the existing ones, you might do something like this:
[code]cp -R newfiles/* files/[/code]
svn add only will add files or directories in the immediate directory unless you explicitly specify each new file or directory to add when you are adding to directories that already exist.
This means that if there is a directory called
images in both
newfiles that is already under version control, and inside of
newfiles/images/ is a new directory called
svn add * from within the
files directory will NOT recursively add it as you might hope it would.
Here is a one-line command-line way to find all new / unknown files using Subversion’s status command and recursively add all of the found files to your current working copy, ready to commit.
[code]svn st | grep ? | sed ‘s/^?[\t]*//;’ | xargs svn add[/code]
This runs Subversion status, then filters the resulting list using grep to find only entries with a ? in front of them (unknown files), then pipes the resulting list through sed to remove the question mark and the leading space, then pipes the resulting set of files / directories into Subversion add using xargs, which operates on each supplied line.