From: Michael Fellinger Date: 2005-12-27T19:46:14+09:00 Subject: Re: Found a neat trick for doing recursive one-liners --nextPart12089810.X6MrFAzrSh Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline I really prefer the simple variant... ruby -e 'puts Dir["**/a*.{rb}"]' finds all .rb that start with 'a', recursive of course :) Am Dienstag, 27. Dezember 2005 11:36 schrieb dblack@wobblini.net: > Hi -- > > On Tue, 27 Dec 2005, 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/} ' > > We've strayed a little from the original thing, but along those lines > you could also do: > > ruby -e 'puts Dir["**/**"].grep(/a\.rb/)' > > (just guessing about the \. part :-) > > or maybe even: > > ruby -e 'puts Dir["**/*a.rb*/"] > > > David --nextPart12089810.X6MrFAzrSh Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBDsRtjMdQeL6eBxhIRAlxWAKCjMUik1zE8WQH5+1slioMiev476wCgjwOs TGNLTzacXvaV6PDJEg8XTbI= =nNiR -----END PGP SIGNATURE----- --nextPart12089810.X6MrFAzrSh--