Shell glob functionality missing?

W

Wayne Magor

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.
 
D

Drew Olson

Wayne said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,675
Latest member
RollandKna

Latest Threads

Top