Skip to content

Instantly share code, notes, and snippets.

@whym
Created May 16, 2010 02:25
Show Gist options
  • Select an option

  • Save whym/402589 to your computer and use it in GitHub Desktop.

Select an option

Save whym/402589 to your computer and use it in GitHub Desktop.
counting script for pipes; try "dmesg | count '^\[\s*(\d+)' 10"
ruby -e'scale=(ARGV[1]||50).to_i; a=STDIN.map{|x| x[Regexp.new(ARGV[0]), 1]}; h=Hash.new{|h_,k| h_[k]=[0,h_.length]}; a.each{|x| h[x]=[h[x][0]+1,h[x][1]]}; puts h.keys.sort_by{|x| h[x][1]}.map{|x| sprintf %q!%s %7d %s!, x, h[x][0], %q{*}*(h[x][0]/scale)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment