.historyの解析
30分プログラム、その128。.historyファイルを解析して、よく使うコマンドを調べてみる。
使い方
$ perl cmd_hist.pl ~/.history ls: ***************************************** cd: *********************************** perl: ***************************** mvn: ****************** sudo: ********* svn: ****
予想通り、lsとcdが多い。perlが多いのは意外だな。
ソースコード
#! /usr/bin/perl # -*- mode:perl; coding:utf-8 -*- # # cmd_hist.pl - # # Copyright(C) 2007 by mzp # Author: MIZUNO Hiroki <hiroki1124@gmail.com> # http://mzp.sakura.ne.jp/ # # Timestamp: 2007/09/08 21:46:02 # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # use strict; use warnings; my %count; while(<>){ if(/;(\w+)\s/){ $count{$1}++; } } my @cmd = sort { $count{$b} <=> $count{$a} } keys %count; foreach (@cmd){ printf "%10s: %s\n",$_,'*' x $count{$_}; }