Created
June 11, 2011 20:55
-
-
Save havenwood/1020949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define a recursive function that will traverse the directory tree | |
def printAndDescend(pattern) | |
#we keep track of the directories, to be used in the second, recursive part of this function | |
directories=[] | |
Dir['*'].sort.each do |name| | |
if File.file?(name) and name[pattern] | |
puts(File.expand_path(name)) | |
elsif File.directory?(name) | |
directories << name | |
end | |
end | |
directories.each do |name| | |
#don't descend into . or .. on linux | |
Dir.chdir(name){printAndDescend(pattern)} if !Dir.pwd[File.expand_path(name)] | |
end | |
end | |
#print all ruby files | |
printAndDescend(/.+\.rb$/) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment