Quantcast
Channel: openSUSE Forums
Viewing all articles
Browse latest Browse all 40713

Delete everything in one directory not present in another

$
0
0
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?

Viewing all articles
Browse latest Browse all 40713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>