indeed. or diectories. that's the nice thing about using select:
ruby -e' puts Dir["**/**"].select{|e| test ?f, e and e =~ /^a\.rb$/} '
-a
···
On Wed, 28 Dec 2005 dblack@wobblini.net wrote:
Hi --
On Wed, 28 Dec 2005, ara.t.howard@noaa.gov wrote:
On Tue, 27 Dec 2005, Philip Rhoades wrote:
ruby -e' puts Dir["**/**"].select{|e| e =~ /a.rb/} '
That doesn't seem to do anything . .
then you probably don't have any files named 'a.rb' under the current
directory - i seem to have several hundred
Or abrb, or acrb, or airbag, or....
--
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
<educational type="but not ruby related">
Not quite. For better (maximum?) robustness, pass '-print0' to find and
'-0' to xargs. That will handle filenames with spaces and/or quotes
correctly. (If your filenames have bytes with binary value zero in them,
you still will be out of luck)
</educational>
Know an OS where that is allowed?
NT 4 kernel mode API is quite happy with \0 in filenames. But it
*really* confuses the Win32 layer! Haven't played with later
versions...
So you need to pass the filename size all over? Ugh.
I was just obliquely pointing out the lack of ^ and \. and $ But
it's true that Dir. is not very seletcive.... In fact, I think I
once submitted an RCR to let it take a second argument that would be
tested for (like: Dir["**/**"],?f]) but it was rejected. So here I am
several years later still acting as if Dir. could read my mind....
David
···
On Wed, 28 Dec 2005, ara.t.howard@noaa.gov wrote:
On Wed, 28 Dec 2005 dblack@wobblini.net wrote:
Hi --
On Wed, 28 Dec 2005, ara.t.howard@noaa.gov wrote:
On Tue, 27 Dec 2005, Philip Rhoades wrote:
ruby -e' puts Dir["**/**"].select{|e| e =~ /a.rb/} '
That doesn't seem to do anything . .
then you probably don't have any files named 'a.rb' under the current
directory - i seem to have several hundred
Or abrb, or acrb, or airbag, or....
indeed. or diectories. that's the nice thing about using select:
ruby -e' puts Dir["**/**"].select{|e| test ?f, e and e =~ /^a\.rb$/} '
--
David A. Black
dblack@wobblini.net
"Ruby for Rails", from Manning Publications, coming April 2006!