Techdragon.info

Techdragon.info

home
home
tools
tools

Compare 2 dirs and copy all the changed files

Ever wanted to compare 2 directories, and then copy all the changed files to a 3rd directory?

diff -r /var/www/html /var/www/release/code --brief --exclude "something" --exclude "else.php" | sed 's/^Only in \([^:]*\): /\1\//' | sed 's/^Files \(.*\) and .* differ/\1/' -> /var/www/release/list.txt

while read p; do
cp --parents $p /var/www/release/new/
done
rm /var/www/release/list.txt