14 ms·
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 {
by anon_mouse 8y ago
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?
- bmn__ 8y agoThat's not how shell quoting works. I don't want to explain the mistake and the fix. Use a shell function instead of an alias, that's the better tool here.
- arccy 8y agoalias 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'