Skip to content

Instantly share code, notes, and snippets.

@hooopo
Created November 27, 2009 00:52
Show Gist options
  • Save hooopo/243751 to your computer and use it in GitHub Desktop.
Save hooopo/243751 to your computer and use it in GitHub Desktop.
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
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