For this directory structure:
.
|-- README.txt
|-- firstlevel.rb
`-- lib
|-- models
| |-- foo
| | `-- fourthlevel.rb
| `-- thirdlevel.rb
`-- secondlevel.rb
3 directories, 5 files
The glob would match:
firstlevel.rb
lib/secondlevel.rb
lib/models/thirdlevel.rb
lib/models/foo/fourthlevel.rb
-
In Ruby itself:
Dir.glob('**/*.rb') perhaps?From James A. Rosen -
In zsh,
**/*.rbworksFrom Chris AtLee -
Looks like it can't be done from
bashIf you using
zshthenls **/*.rbwill produce the correct result.
Otherwise you can hijack the
rubyinterpreter (and probably those of other languages)ruby -e "puts Dir.glob('**/*.rb')"Thanks to Chris and Gaius for your answers.
From quackingduck -
Apologies if I've missed the real point of the question but, if I was using sh/bash/etc., then I would probably use find to do the job:
find . -name '*.rb' -type fGlobs can get a bit nasty when used from within a script and find is much more flexible.
From Nick
0 comments:
Post a Comment