Re:Your top 100 unix commands, for science
by __david__ on Sunday May 19, 2013 @03:12PM
(#5734051)
"\r" doesn't work either. It's just not interpreting those kind of escapes. I get lines like this:
The for loop is a good idea, though I prefer the "while read" idiom since it fits in with the pipeline better:
That finally works for me. Here's the whole thing:
[ Parent
| on HN ]
This works for me in zsh on OSX
history \ | sed "s/^[0-9 ]//" \ | perl -pe 's/ \| */\n/g' \ | gawk '{counts[$1] += 1} END { for (x in counts) { print counts[x],x}}' OFS="\t" \ | column -t \ | sort -k 1,1nr \ | head -100
Ok not sure how to format this on HN https://gist.github.com/nyxwulf/5608955#file-gistfile1-sh
From what I recall to represent s newline in sed on osx you need to add an actual carriage return.
Take the poster's script above and copy it to a text file. Now replace \n with a new line, save and it should run.