Shell glob functionality missing?

If you call a Ruby script with a parameter such as:

c:\my source**.c

Ruby will give an array in ARGV that contains all the c files in all
the directories. It will also turn the backslashes into forward
slashes. There doesn’t seem to be a method in Ruby that does this
same thing. The Dir.glob and Dir.entries methods don’t work this way.

Am I missing something, or is there no easy built-in method for doing
this in Ruby? Doesn’t it seem like it should be there? I would think
this would be a common thing for scripting.

Wayne M. wrote:

If you call a Ruby script with a parameter such as:

c:\my source**.c

Ruby will give an array in ARGV that contains all the c files in all
the directories. It will also turn the backslashes into forward
slashes. There doesn’t seem to be a method in Ruby that does this
same thing. The Dir.glob and Dir.entries methods don’t work this way.

Am I missing something, or is there no easy built-in method for doing
this in Ruby? Doesn’t it seem like it should be there? I would think
this would be a common thing for scripting.

Dir.glob(“c:\mysource***.c”)

Use two *, that allows recursive directory searching with glob.

  • Drew

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs