论坛首页 编程语言技术论坛

在给定路径中搜索符合给定模式的文件

浏览 5913 次
精华帖 (0) :: 良好帖 (5) :: 新手帖 (0) :: 隐藏帖 (7)
作者 正文
   发表时间:2009-11-24  
ray_linn 写道
poshboytl 写道
ray_linn 写道
222xiaohuan 写道
那你应该加上对你来说没有意义,对于我们这些水平低的人很多东西还是很有意义的。


嘿嘿,你不知道robbin一向风格是不欢迎新手么



你就是自认为自己要不完了... 

robbin文风的确犀利... 但是别人说的有道理, 有价值...

我不是不喜欢抨击.... 相反我很喜欢有意义有价值的抨击....

很多东西要辩才能有更好的解决方案....

你看你的抨击有价值吗???


笑眯眯走过~


不送, 希望你永远不要回来了....
0 请登录后投票
   发表时间:2009-11-26  
night_stalker 写道
囧啊,本来一行就能搞定的事情 ……
Dir.glob '*.rb'


再说 find 这个命令无论在 windows 还是 linux 还是 mac 都能用的 ……

貌似rake自带的FileList和Dir.glob是一样的。一个简单的rake:

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

结果:
"db/migrate/066_remove_sessions_table.rb"
"db/migrate/067_add_timezone_to_setting.rb"
"db/migrate/068_move_bans_to_users_table.rb"
"db/migrate/069_create_messages.rb"
"db/migrate/070_add_indexed_to_messages.rb"
"db/migrate/071_add_private_to_settings.rb"
"db/migrate/072_add_login_message_to_settings.rb"
"db/migrate/073_removing_privacy_from_individual_models.rb"
"db/migrate/074_all_nil_users_online_at.rb"
"db/migrate/075_add_chatting_at_to_users.rb"
"db/migrate/076_add_indexes_for_chat.rb"
"db/migrate/077_add_logged_out_at_to_users.rb"
"db/migrate/078_fix_indexes.rb"
"db/migrate/079_add_logged_out_for_all_users.rb"
"db/migrate/080_fix_user_indexes.rb"
"db/migrate/081_add_sticky_index_to_topics.rb"
"db/migrate/082_change_to_logged_out_for_users.rb"
"db/migrate/083_remove_user_index_on_logged_out_at.rb"
"db/migrate/20080526190223_remove_limit_on_users_bio.rb"
"db/migrate/20080603023415_use_rails_new_default_time_zones.rb"
"db/migrate/20080603035014_move_time_zone_default_to_setting_model.rb"
"db/migrate/20080603230322_use_rails_new_default_time_zones_for_settings_too.rb"
"db/migrate/20080712034609_create_articles.rb"
"db/migrate/20080712230439_add_articles_count_to_users.rb"
"db/migrate/20080725023025_create_comments.rb"
"db/migrate/20080725023050_add_comments_counter_cache_to_articles.rb"
"db/migrate/20080727205027_add_admin_only_create_setting.rb"
"db/migrate/20080927025905_create_viewings.rb"
"db/migrate/20081002051832_add_all_viewed_at_to_users.rb"
"db/migrate/20081015052225_add_index_to_viewings.rb"
"db/migrate/20090627234146_attachment_fu_to_paperclip_part_one.rb"
"db/migrate/20090701005540_attachment_fu_to_paperclip_part_two.rb"
"db/migrate/20090702030411_reset_current_theme.rb"
"db/schema.rb"
"lib/authentication_system.rb"
"lib/exception_handler.rb"
"lib/migrator.rb"
"lib/paperclip_support.rb"
"public/dispatch.rb"
"test/blueprints.rb"
"test/functional/articles_controller_test.rb"
"test/functional/avatars_controller_test.rb"
"test/functional/categories_controller_test.rb"
"test/functional/comments_controller_test.rb"
"test/functional/events_controller_test.rb"
"test/functional/forums_controller_test.rb"
"test/functional/headers_controller_test.rb"
"test/functional/home_controller_test.rb"
"test/functional/messages_controller_test.rb"
"test/functional/posts_controller_test.rb"
"test/functional/ranks_controller_test.rb"
"test/functional/search_controller_test.rb"
"test/functional/settings_controller_test.rb"
"test/functional/subscriptions_controller_test.rb"
"test/functional/themes_controller_test.rb"
"test/functional/topics_controller_test.rb"
"test/functional/uploads_controller_test.rb"
"test/functional/users_controller_test.rb"
"test/integration/admin_only_create_test.rb"
"test/integration/exception_handler_test.rb"
"test/integration/fixture_validation_test.rb"
"test/integration/home_page_chat_test.rb"
"test/remote/uploads_controller_test.rb"
"test/remote/upload_test.rb"
"test/test_helper.rb"
"test/unit/article_test.rb"
"test/unit/avatar_test.rb"
"test/unit/category_test.rb"
"test/unit/comment_test.rb"
"test/unit/event_test.rb"
"test/unit/forum_test.rb"
"test/unit/header_test.rb"
...

0 请登录后投票
   发表时间:2009-11-27  
支持 ray_linn , 技术人员不用怕被抨击,没有最好,只有更好!
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics