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 1 167 16.7% git 2 130 13% ll 3 94 9.4% clear 4 90 9% make 5 80 8% cd 6 57 5.7% e 7 52 5.2% cat 8 45 4.5% man 9 38 3.8% valgrind 10 37 3.7% rm Where ´e´ is an alias for ´vim´.
I can copy/paste your statement and it works.. but when I try to save it as an alias method.. I keep getting error: awk: cmd. line:1: {CMD[]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;} awk: cmd. line:1: ^ syntax error awk: cmd. line:1: error: invalid subscript expression I thought I would just escape the double quotes ", and things would work. :/ Any ideas?
alias mostused='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'