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.
If you also want to remove "other" things from your history, all you need to change is the regular expression that matches the word "bogus".
#!/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);
If you also want to remove "other" things from your history, all you need to change is the regular expression that matches the word "bogus".
•
[4,387 views]

