Answer the question
In order to leave comments, you need to log in
How to remove the difference between two directories?
There are 2 directories: dir1 and dir2. How can I recursively remove all subdirectories and files from dir2 that are not in dir1 ?
Answer the question
In order to leave comments, you need to log in
Maybe rsync will help?
rsync \
-av \
--delete \
--existing \
dir1 dir2
diff -r dir1/ dir2/ |grep Only | sed -e 's/^.*Only in //' -e '[email protected]: @/@' | xargs rm
Upd: but Sergey Sokolov 's answer is certainly prettier
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question