Jump to content

Ruby One Liners

From EggeWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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

<geshi lang="ruby">

  1. 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 ' </geshi>

Parse Awstats html output. <geshi lang="ruby"> ruby -ne 'if $_ =~ /href="http:\/\/www.theeggeadventure.com\/(.*?)".*?([0-9]+).*?([0-9.]+) KB/ then puts "#{$1}\t#{$2}\t#{$3}" end ' \

< awstats.pl | putclip

</geshi>