Created
November 27, 2009 00:52
-
-
Save hooopo/243751 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
require 'find' | |
puts "input your dir:" | |
dir = gets.chomp | |
puts "input your pattern:" | |
pattern = gets.chomp | |
Find.find(dir) do |file| | |
puts file if File.file?(file) && File.basename(file) =~/#{pattern}/ | |
end |
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
namespace :file do | |
desc "rake search file demo" | |
task :search do | |
Dir.chdir ENV["dir"]||"." | |
FileList[ENV["pattern"]].each do |file| | |
p file | |
end | |
end | |
end | |
#C:\workspace\eldorado>rake file:search pattern=**/*.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment