Friday, June 3, 2011

Get percentage of Command executed



Do you want to know which command on you Linux box has executed the most and also would you like to get the Percentage. This is very Simple and can be achieved useing awk, grep. It can be acheived in many other possible ways too.
root# 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
OutPut:

1 133 13.3% ls
2 127 12.7% cd
3 78 7.8% vi
4 35 3.5% netstat
5 32 3.2% postfix
6 31 3.1% tail
7 30 3% mv
8 29 2.9% telnet
9 29 2.9% ll
10 23 2.3% postqueue

No comments:

Post a Comment

 Linux Interview  Linux booting process EXT4 XFS file system runlevel scan disk hba driver systool -c fc_host lspci -nn | grep -i hba single...