Ruby One Liners

From EggeWiki

Jump to: navigation, search

Find duplicate class files in multiple jars. Tip: run this in your JBoss lib directory.

# If a class file has a different size in a different jar file you might have a problem on your hands
find . -type f -name "*.?ar" -print -exec jar tvf {} \; \
| ruby -ne 'BEGIN{ $h={}  }; puts $_ if $_ =~ /.*.jar$/; if $_ =~ /([0-9]+).{31}(.*)/ then $h[$2] ||= $1; puts $2 + " size " + $1 + " != " + $h[$2] if $h[$2] != $1; end '

Parse Awstats html output.

ruby -ne 'if $_ =~ /href="http:\/\/www.theeggeadventure.com\/(.*?)".*?([0-9]+).*?([0-9.]+) KB/ then puts "#{$1}\t#{$2}\t#{$3}" end ' \
 < awstats.pl | putclip
Personal tools
Travelling Salesman

Get the app!