Re: Delete everything in one directory not present in another

Originally Posted by
MirceaKitsune
A little something slightly outside my bash scripting skills; I want to make a script which deletes everything in one path not present in another path. It must be fully recursive, so it applies to all files / folders / subfolders inside the two paths. For example, if I have:
/foo1/bar1.txt
/foo2/bar1.txt
/foo2/bar2.txt
The command would delete /foo2/bar2.txt because the file isn't also present in /foo1, but keep /foo2/bar1.txt because it is. Does anyone know of a shell script that takes both base folders as arguments and does this?
Install Unison and use that. I use it all the time to keep 2 NTFS partitions synchronized, as well as to keep individual Linux paths synchronized.
It is superb for that purpose, and is in the openSUSE repositories.
-Gerry Makaro
Fraser-Bell Info Tech
Solving Tech Mysteries since the Olden Days!
~~
If I helped you, consider clicking the Star at the bottom left of my post.
Bookmarks