Created
January 26, 2013 13:24
-
-
Save perforb/4642371 to your computer and use it in GitHub Desktop.
.(BASH|ZSH)_HISTORY CLEANER - Delete duplicate rows as keeping the order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature qw(say); | |
my @lines; | |
while (<>) { | |
chomp; | |
next unless $_; | |
push @lines, $_; | |
} | |
my %seen; | |
my @uniq = grep { ++$seen{$_} < 2 } @lines; | |
say $_ for @uniq; | |
__END__ | |
=head1 NAME | |
.(BASH|ZSH)_HISTORY CLEANER | |
=head1 DESCRIPTION | |
Delete duplicate rows as keeping the order. | |
=head1 USAGE | |
cat ~/.zsh_history | perl history_cleaner.pl > ~/.zsh_history.tmp; mv ~/.zsh_history.tmp ~/.zsh_history |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat ~/.zsh_history | perl history_cleaner.pl > ~/.zsh_history.tmp; mv ~/.zsh_history.tmp ~/.zsh_history |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment