老男孩教育每日一题-2017年4月5日-统计你的linux系统的history历史记录,得出你最喜欢使用的前10个命令
2017-04-05 20:35
681 查看
统计你的linux系统的history历史记录,得出你最喜欢使用的前10个命令
方法一:awk数组方法[root@show ~]# history |awk '{h[$2]++}END{for(key in h)printkey,h[key]}' |sort -rnk2|head awk 279 ll 78 cat 66 cd 41 ls 34 find 32 echo 32 man 30 sed 27 vim 26
#优雅的显示可以加上 |column -t 即可
[root@show ~]# history |awk '{h[$2]++}END{for(key in h)print key,h[key]}' |sort -rnk2|head |column -t awk 279 ll 78 cat 66 cd 41 ls 34 find 32 echo 32 man 30 sed 27 vim 26方法二:简单处理法
[root@show ~]# history |awk '{print $2}'|sort |uniq -c |sort-rn|head 279 awk 78 ll 66 cat 41 cd 34 ls 32 find 32 echo 30 man 27 sed 26 vim如果对awk数组的执行过程还是不理解请参考,
http://lidao.blog.51cto.com/3388056/1912219
【4月8日】价值18800的MySQL DBA高能必杀技免费送你!
http://mp.weixin.qq.com/s/nVP8s2oQw3arrK8Hyy6Ftw
相关文章推荐
- 老男孩教育每日一题-第69天-shell脚本知识点:linux系统脚本中trap信号都有哪些,如何进行使用?
- linux下history命令显示历史指令记录的使用方法
- 老男孩教育每日一题-2017年4月7日-请给出linux中查看系统已经登录用户的命令
- 老男孩教育每日一题-2017-04-21-命令风暴--查看你的Linux系统的文件系统类型?
- linux下history命令显示历史指令记录的使用方法
- 老男孩教育每日一题-2017年5月2日-Linux系统中,不小心把chmod命令的权限弄没了,怎么解决?
- linux下历史命令history使用方法
- [转载]linux查询历史记录命令history的用法介绍
- linux删除或隐藏命令历史记录history
- Linux中history历史命令使用方法详解
- Linux 下删除 History 历史命令记录的方法
- Linux系统下history命令的记录如何删除
- linux统计使用最多的10个命令
- 【转】Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- 如何使linux系统下的root用户不保存终端历史记录到.bash_history中
- Linux Oracle下sqlplus无法使用命令退格删除和历史记录的解决方法(使用rlwrap)
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中命令历史history及man帮助手册的相关理解和使用