Reputation: 17181
I have a list of files in my current working copy that have been modified locally. There are about 50 files that have been changed.
I can get a list of these files by doing this:
svn st | ack '^M'
Is there a way I can copy these files and only these files to another directory, which is called backup
?
Upvotes: 3
Views: 4571
Reputation: 349
That works for me:
svn status | grep ^M | awk '{print $2}' | xargs -I '{}' cp --parents {} /backup/
Upvotes: 0
Reputation: 2201
In Windows 8, can use this command in current svn directory:
(FOR /F "tokens=2 delims== " %i IN ('svn st ^| findstr "^[ADMR]"') DO @echo %i & echo f| xcopy /f /y %i c:\projects\backup\%i)
Upvotes: 1
Reputation: 3162
svn status | grep '^[ADMR]' | cut -b 8- | xargs -I '{}' rsync -R {} /directry/
Upvotes: 2
Reputation: 18864
This would do (bash):
#!/bin/bash
set -eu
# for each modified file
for f in $(svn st| awk '/^M/{print $2}'); do
# create a directory under backup root and copy the file there
mkdir -p .../backup/${f%/*} && cp -a $f .../backup/$f
done
Upvotes: 1
Reputation: 10839
Assuming ack is like grep... you could do something like:
cp `svn st | ack '^M' | cut -b 8-` backup
I'd post this as a comment... but I don't know how to escape the backticks in comments...
Upvotes: 5