#! /usr/bin/perl
chdir;
system "tac <.bash_history >.bash_history.new1";
open(orig, "<.bash_history.new1");
open(dest, ">.bash_history.new2");
while ( <orig> ) {
    $line=$_;
    if ( ! (exists $history{$line}) ) {
	print dest $line;
	$history{$line}="";
    }
}
close(orig);
close(dest);
system "tac <.bash_history.new2 >.bash_history";
unlink ".bash_history.new1", ".bash_history.new2";
