# Shell glob functionality missing?

**URL:** <https://www.ruby-forum.com/t/shell-glob-functionality-missing/125416>\
**Category:** Ruby\
**Created:** [January 8, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/shell-glob-functionality-missing/125416 "2008-01-08T22:56:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [January 8, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/shell-glob-functionality-missing/125416/1 "2008-01-08T22:56:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [January 8, 2008, 11:46pm UTC](https://www.ruby-forum.com/t/shell-glob-functionality-missing/125416/2 "2008-01-08T23:46:34Z")

</div>

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
