|
@@ -0,0 +1,39 @@
|
|
|
+#!/usr/bin/perl
|
|
|
+
|
|
|
+use strict;
|
|
|
+use warnings;
|
|
|
+
|
|
|
+our %commands;
|
|
|
+
|
|
|
+open(HISTORY, "$ENV{HOME}/.histfile") || die "Cannot open history file: $!\n";
|
|
|
+
|
|
|
+
|
|
|
+sub hashValueDescendingNum {
|
|
|
+ $commands{$b} <=> $commands{$a};
|
|
|
+}
|
|
|
+
|
|
|
+while (<HISTORY>) {
|
|
|
+ my $command = $_;
|
|
|
+
|
|
|
+ my @comm = split(' ', $command);
|
|
|
+
|
|
|
+ if ($comm[0] eq "sudo") {
|
|
|
+ shift @comm;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($comm[0] eq "..") {
|
|
|
+ next;
|
|
|
+ }
|
|
|
+
|
|
|
+ $comm[0] =~ s/\.\///;
|
|
|
+
|
|
|
+ if (not exists($commands{$comm[0]})) {
|
|
|
+ $commands{$comm[0]} = 0;
|
|
|
+ }
|
|
|
+ $commands{$comm[0]}++;
|
|
|
+}
|
|
|
+
|
|
|
+foreach my $key (sort hashValueDescendingNum (keys(%commands))) {
|
|
|
+ my $value = sprintf "%8s", $commands{$key};
|
|
|
+ print "$value\t$key\n";
|
|
|
+}
|