shithub: 9intro

ref: a351bcdccdf5a4273bc8dc3360a48fbb8b8aa9ea
dir: /src/restore/

View raw version
#!/bin/rc
rfork e
if (! ~ $#* 2){
	echo usage $0 olddir newdir >[1=2]
	exit usage
}
old=$1
new=$2
diffs=/tmp/restore.$pid
diff -r $old $new >$diffs
grep '^Only in '^$new /tmp/diffs | sed -e 's|Only in|rm|' -e 's|: |/|'
fromstr='Only in '^$old^'/(.+): ([^ ]+)'
tostr='cp '^$old^'/\1/\2 '^$new^'/\1'
grep '^Only in '^$old  $diffs |  sed -e 's|'^$fromstr^'|'^$tostr^'|'
grep '^diff ' $diffs | sed 's/diff/cp/'
rm $diffs
exit ''