0

我正在尝试ag使用正则表达式通过管道获得结果,但它不起作用。

~/c/octoly git:1470 ❯❯❯ drake routes | ag pro_store --page=less -r                                                                                                                                        
Running via Spring preloader in process 9140
                                   pro_store_stores_users POST                /pro/stores/:store_id/stores_users(.:format)                                 pro/stores_users#create
                                new_pro_store_stores_user GET                 /pro/stores/:store_id/stores_users/new(.:format)                             pro/stores_users#new
                               edit_pro_store_stores_user GET                 /pro/stores/:store_id/stores_users/:id/edit(.:format)                        pro/stores_users#edit
~/c/octoly git:1470 ❯❯❯ drake routes | ag '^pro_store' --page=less -r                                                                                                                                     
Running via Spring preloader in process 8669
~/c/octoly git:1470 ❯❯❯ drake routes | ag ^pro_store --page=less -r                                                                                                                                       
Running via Spring preloader in process 8743
rake aborted!
Errno::EPIPE: Broken pipe @ io_write - /dev/ttys010
/Users/adrien/.gem/ruby/2.2.4/gems/railties-4.2.6/lib/rails/tasks/routes.rake:6:in `write'
/Users/adrien/.gem/ruby/2.2.4/gems/railties-4.2.6/lib/rails/tasks/routes.rake:6:in `puts'
/Users/adrien/.gem/ruby/2.2.4/gems/railties-4.2.6/lib/rails/tasks/routes.rake:6:in `puts'
/Users/adrien/.gem/ruby/2.2.4/gems/railties-4.2.6/lib/rails/tasks/routes.rake:6:in `block in <top (required)>'
/Users/adrien/.gem/ruby/2.2.4/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/Users/adrien/.gem/ruby/2.2.4/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
/Users/adrien/.gem/ruby/2.2.4/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/adrien/.gem/ruby/2.2.4/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
-e:1:in `<main>'
Tasks: TOP => routes
(See full trace by running task with --trace)

我试图从pro_store. 我已经读过损坏的管道可能是因为这些ag东西在这些东西之前结束,drake但我不明白如果这真的发生了什么以及为什么会这样。

4

1 回答 1

0

尝试drake routes | ag "^ *pro_store" --page=less -r

您的输出不是“开始” pro_store,而是多个空格,然后 pro_store. 这就是为什么要[:space:]*添加到您的正则表达式。

于 2016-04-20T12:28:13.817 回答