#!/usr/bin/perl -n
# This is specifically for removing redundant files across my old backups.
# Its input is the one_in_base file or many_in_base file output by "removable"
# it outputs a list of files that are not in the base dir

use IO::File;

BEGIN {
	@ARGV or die "syntax: removable base-dir\n  e.g.:  removable ./sam\n";
	$base = shift;
	$base =~ s,/$,,;
}

chomp;
if ($_ eq "") {
	# got a group
	# sanity check
	$in_base = shift @group;
	if ($in_base !~ m,^$base/,o) {
		die "1st in group not in base dir: $in_base";
	}
	for (@group) {
		if (!m,^$base/,o) {
			print "$_\n";
		}
	}
	@group = ();
} else {
	push @group, $_
}
