Diff a Tree and Copy

Posted by Dave Minor Mon, 05 Mar 2007 20:32:00 GMT

When maintaining older projects that don’t have deployment scripts written and where production is not under version control, I find a lot of times that I need to diff the two directory trees looking for which files have changed and then copy them to production.

Today I had a bunch of those to do. I worked up a shell one-liner that will handle this and I’m posting it here to remember the next time this comes up.

diff -q -x .svn -r . ../production_root | awk '{print $2}' | xargs -i -t cp {} path/to/production_root/{}

Let me know if you see a better way.

UPDATE: ok, so this totally fails when there are files in the current tree that don’t exist in the production_root because my awk outputs ‘in’ instead of the filename.

I guess I really need to suck it up and implement a capistrano deployment system for my non-rails apps.

Posted in ,  | no comments

Comments

Comments are disabled