From: Zak Greant Date: 2003-03-18T04:45:14+09:00 Subject: Re: irb as a shell On Tue, Mar 18, 2003 at 04:22:45AM +0900, Mark Wilson wrote: > Just a note. > > In the past day or two I've started to use irb as a shell to work in, > and it's very helpful, although not earth-shattering. > > For example, I did the following in irb to unzip a bunch of files in my > working directory: > > system("ls *gz > list") > a=File.open("list","r") > b=a.readlines > b.each { |f| system("gtar -zxf #{f}") } > b.each { |f| system("rm -rf #{f}") } > > I think this could be done with an ordinary shell, using xargs maybe, > but I know how to do it in Ruby. If you have a more elegant way to > write the Ruby lines, let me know. Looking at it, I can see that if I > remembered the directory methods I could make the first 3 lines one > line. Something like this should work. Dir["*gz].each{ |f| `gtar -xzf #{f} && rm #{f}`} Cheers --zak