#!/usr/bin/perl

# EDIT THESE TWO LINES#######################################
my $manpathFile		= "/usr/share/misc/man.conf";
my $pathToDelete	= "/Library/Filesystems/Xsan/man";
#############################################################

my $target_disk = $ARGV[2];
my $fileName = $target_disk . $manpathFile;


# 1: Find a name for a backup copy of the manpath file
my $backupFileName = $fileName . ".applesaved";

if (-e $backupFileName) {
	my $N = 2;

	while (-e $backupFileName . $N) {
		$N = $N + 1;
	}
	$backupFileName = $backupFileName . $N;
}

# Move the file to the backup
system("/bin/mv", "-f", $fileName, $backupFileName);

# Now use grep to put the modified file in the old location
# grep -v "/Library/Filesystems/Xsan/man" man.conf > man.conf.new

system("/usr/bin/grep -v \"$pathToDelete\" \"$backupFileName\" > \"$fileName\"");


exit 0;