From: x1 Date: 2005-12-27T13:50:48+09:00 Subject: Re: Found a neat trick for doing recursive one-liners Ara, I always love your examples! :-) Please keep contributing to the community!! BTW, I have the process management class working like a champ.. I'll share the code with you later! On 12/26/05, ara.t.howard@noaa.gov wrote: > On Tue, 27 Dec 2005, Gary Watson wrote: > > > This is probably something everyone in here already knows about, but I > > thought it was cool enough that I wanted to post about it. > > > > If you want to create a one liner to say search all the *.txt files > > in and under the current directory for text matching "Hello", you can do > > this > > > > find -name '*.txt' -exec ruby -ne 'print if /Hello/' '{}' ';' > > > > I know you can do this in pure ruby in like 3 lines if you use the Find > > module, but I really wanted to do it with a one liner. Earlier I tried > > something like this > > > > ruby -ne 'print if /Hello/' `find -name '*.txt'` > > ruby -e' puts Dir["**/**"].select{|e| e =~ /a.rb/} ' > > -a > -- > =============================================================================== > | ara [dot] t [dot] howard [at] noaa [dot] gov > | all happiness comes from the desire for others to be happy. all misery > | comes from the desire for oneself to be happy. > | -- bodhicaryavatara > =============================================================================== > > >