分页: 1 / 1

如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-22 16:22
piggyZhao
如题

我的想法是使用lastcomm命令,然后再使用排序找出前10条命令
但是不知道要怎么用lastcomm命令只打印使用过的命令而没有详细信息好存进一个文本文件中进行比较

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-22 16:32
nmsfan
坛子有个神贴
昨天还顶过了
不知道在哪个区
就是贴你最常用的10个命令
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-22 17:19
piggyZhao
nmsfan 写了:坛子有个神贴
昨天还顶过了
不知道在哪个区
就是贴你最常用的10个命令
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
。。。真牛。。。那个帖子大概叫什么名呀?

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-23 16:47
tusooa
水区的帖子.

代码: 全选

tlcr: 0 2011-06-23 16:38 tusooa-laptop ~ 
● which topx 
topx () {
        history 0 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | GREP_COLOR="$(echo 3$[$(date +%N)%6+1]';1;4;40')" egrep --color=always -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n "$1"
}
tlcr: 0 2011-06-23 16:45 tusooa-laptop ~ 
● 

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-23 16:49
daf3707
有贴,或者帖子标题下的技巧里有

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-23 16:50
月下叹逍遥
viewtopic.php?f=15&t=94661
你最常用的10条命令是?
在水区置顶贴里有

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-23 16:51
nmsfan
piggyZhao 写了:
nmsfan 写了:坛子有个神贴
昨天还顶过了
不知道在哪个区
就是贴你最常用的10个命令
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
。。。真牛。。。那个帖子大概叫什么名呀?
记不得了,翻bash记录翻出来的

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-06-26 9:58
gzbao9999
悄悄自己写了个

代码: 全选

tail -1000 .bash_history |sort|uniq -c|sort -k1nr|head -10
话说那个history指令 有没有不显示行号的参数?

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-07-05 23:00
fnan
遍历历史记录中的指令包括管道后的sudo后的:
for i in $(sed -E 's#\(|\)|\[|\]|\{|\}|\.|\/|[^a-z]-# #g' ~/.bash_history);do if type -p $i &>/dev/null;then echo $i;fi;done|sort|uniq -c|sort -nk1

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-07-05 23:15
长头发的和尚
那帖见过好几次 :em04

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-07-06 0:00
mianzhi
gzbao9999 写了:悄悄自己写了个

代码: 全选

tail -1000 .bash_history |sort|uniq -c|sort -k1nr|head -10
话说那个history指令 有没有不显示行号的参数?
电脑辛苦了;我也辛苦了。

代码: 全选

mianzhi@mianzhi-laptop:~$ tail -1000 .bash_history |sort|uniq -c|sort -k1nr|head -10
    127 make
     98 ./teflon3dFVM 
     76 exit
     45 make clean
     42 ls
     23 top
     22 heat3dFVM 
     17 ./teflon 
     16 g++ test.cpp 
     14 ./a.out

Re: 如何打印出系统最近使用的1000条命令中最多的10条

发表于 : 2011-07-06 8:33
lexdene
围观各种大牛。