Hi -- On Fri, 2 Jan 2009, Alain Helfenstein wrote: > Hi, > > I try to write a Ruby one-liner that replaces the header information of > some *.java files. > > My first try worked perfect for a single file. But I have no idea on how > to change my one-liner to work with multiple files. > > Here is my one-liner for a single file: > > ruby -i.bak -p -e 'puts ARGF.read.gsub(/.*(?=package)/m,"/**\n * foo.bar > 2001-2009\n\ **/\n")' test/Test.java > > Does anybody have a idea on how to solve this problem for all *.java > files in the test directory? The -p flag will do the read/write loop for you, so all you have to do is something like this: $ cat abc.txt hello $ cat def.txt goodbye $ ruby -pi.bak -e '$_.upcase!' abc.txt def.txt $ cat abc.txt HELLO $ cat def.txt GOODBYE David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!