# (Dir.glob("#{@path}/\*\*/\*/\*\*") | Dir.glob("#{@path}/\*\*")) != Dir.glob("#{@path}/\*\*")?

**URL:** <https://www.ruby-forum.com/t/dir-glob-path-dir-glob-path-dir-glob-path/148120>\
**Category:** Rails\
**Created:** [September 9, 2008, 3:24pm UTC](https://www.ruby-forum.com/t/dir-glob-path-dir-glob-path-dir-glob-path/148120 "2008-09-09T15:24:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dracko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c89c15/32.png) [@dracko](https://www.ruby-forum.com/u/dracko)\
**Post date:** [September 9, 2008, 3:24pm UTC](https://www.ruby-forum.com/t/dir-glob-path-dir-glob-path-dir-glob-path/148120/1 "2008-09-09T15:24:13Z")

</div>

I tried to ask this question once in Ruby-talk and inside another post  
in  
this list. No one answered me and I doubt anyone is able to answer it.

So, I tried changing the subject in a weird, although correct question,  
to  
see if someone could help me.

In actionpack/lib/action\_view/paths.rb, there is the following snippet:

def templates\_in\_path  
(Dir.glob("#{@path}/ **/\*/**") | Dir.glob("#{@path}/\*\*")).each do  
|file|  
unless File.directory?(file)  
yield Template.new(file.split("#{self}/").last, self)  
end  
end  
end

That got me intrigued. What is the difference between  
Dir.glob("#{@path}/ **/\*/**") | Dir.glob("#{@path}/**")  
and just  
Dir.glob("#{@path}/**")  
?

Thanks, Rodrigo.

---

<div class="post-metadata">

**Author:** ![dracko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c89c15/32.png) [@dracko](https://www.ruby-forum.com/u/dracko)\
**Post date:** [September 9, 2008, 3:40pm UTC](https://www.ruby-forum.com/t/dir-glob-path-dir-glob-path-dir-glob-path/148120/2 "2008-09-09T15:40:41Z")

</div>

On 9 Sep 2008, at 14:27, Rodrigo Rosenfeld R. wrote:

> snippet:  
> That got me intrigued. What is the difference between  
> Dir.glob("#{@path}/ **/\*/**") | Dir.glob("#{@path}/\*\*")  
> and just

Did you try running them ? Two minutes in the console seems to  
indicate that “#{@path}/ **/\*/** ” matches files inside those folders as  
many levels down as you want

whereas "#{@path}/\*\* just lists those folders in @path

Fred

> Dir.glob("#{@path}/\*\*")

---

<div class="post-metadata">

**Author:** ![dracko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c89c15/32.png) [@dracko](https://www.ruby-forum.com/u/dracko)\
**Post date:** [September 9, 2008, 4:04pm UTC](https://www.ruby-forum.com/t/dir-glob-path-dir-glob-path-dir-glob-path/148120/3 "2008-09-09T16:04:46Z")

</div>

Frederick C. wrote:

> > question, to  
> > end
> 
> whereas "#{@path}/\*\* just lists those folders in @path
> 
> Fred

Ok, I got, they are different. But playing a bit more with glob, I found  
out  
that (or, at least, it seems to):

Dir.glob("#{@path}/\*\*") == Dir.glob("#{@path}/\*")

and  
(Dir.glob("#{@path}/ **/\*/**") | Dir.glob("#{@path}/**")) ==  
(Dir.glob("#{@path}/**/_/\*\*") | Dir.glob("#{@path}/_")) ==  
Dir.glob("#{@path}/\*\*/\*")

Except for order. To be sure, try this:  
(Dir.glob("#{@path}/ **/\*/**") | Dir.glob("#{@path}/_")).sort ==  
Dir.glob("#{@path}/\*\*/_")Dir.glob("#{@path}/\*\*/\*").sort

So, I would change my question:

Wouldn’t  
Dir.glob("#{@path}/**/\*")  
be a better replacement to  
Dir.glob("#{@path}/ **/\*/**") | Dir.glob("#{@path}/**")  
?

Rodrigo.
