Home > Uncategorized > That history meme

That history meme

April 14, 2008

Python version, shorter than Paddy‘s version:

# history|python -c'import sys;c=[i.split()[1] for i in sys.stdin]; [sys.stdout.write("%s %s\n"%x) for x in sorted(set((c.count(i),i) for i in c), key=lambda (a,b):a)[::-1][:10]]'
198 python
71 ab
37 cat
36 /root/python/bin/python
31 cd
21 nc
21 strace
10 echo
9 history
8 easy_install

Still not shorter than the bash version:

history|awk '{a[$2]++} END{for(i in a){print a[i]" "i}}'|sort -rn|head
About these ads
Tags:
  1. May 17, 2008 at 7:11 pm

    … Never thought someone else would be as masochistic :-)

    - Paddy.

  1. No trackbacks yet.
Comments are closed.
Follow

Get every new post delivered to your Inbox.

Join 172 other followers