If you've enabled the Debug menu in Safari, you may have noticed the "Populate History" item. If you ... accidently ... click it, it fills your history with up to 1000 bogus sites. I've written a perl script that removes them.
#!/usr/bin/perlCopy that into a text editor, make it executable (chmod +x history.pl). All that needs to be changed is the username ("jmelloy"). It's non-destructive, it creates a new file in the same directory you ran the script from. Then, all you need to do is copy the new History.plist file to ~/Library/Safari/History.plist and you're done.
use warnings;
use strict;
my $file="/Users/jmelloy/Library/Safari/History.plist";
$/="<array>";
open(FILE,$file) or die qq(Unable to open "$file": $!);
my $toss = <FILE>;
$/="</dict>";
my @history = <FILE>;
close(FILE);
my $outfile = "History.plist";
open(OUTFILE, ">$outfile") or die qq{Unable to open "$outfile": $!};
print OUTFILE $toss;
for(my $i = 0; $i < @history; $i++) {
if($history[$i] =~ /.*bogus.*/) {
}
else {
print OUTFILE $history[$i];
}
}
close(OUTFILE);
Mac OS X Hints
http://hints.macworld.com/article.php?story=20030204064320899