Linux SVN 1-Liner: Add all new files except Dreamweaver LCK files
If you’re using DreamWeaver without its built-in Subversion support, or for whatever reason need to add newly-created files (that may still be checked out) to the repository, this one liner will do the trick:
svn st | grep "^\?" | grep -v ".LCK$" | awk '{print $2}' | xargs svn add |
Let’s break it down, by pipes (reading left to right):
- Give me a subversion status: a list of all files that have been added, modified, or otherwise
- Using grep, only select those that start with a “?”, namely those files added to the working copy, but not yet under version control
- Using reverse grep (the -v switch), exclude any of those records where the filename ends with “.LCK” (the DreamWeaver lock file that indicates something is checked out)
- Using AWK, only output the second field (which translates to the filename without all the SVN flags in front of it)
- Using XARGS, pipe this (now filtered) list of files to the svn add command.
