我尝试使用正则表达式通过管道获得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
之前结束了,但我不明白为什么如果真的如此&#39}发生了。
答案 0 :(得分:0)
尝试使用drake routes | ag "^ *pro_store" --page=less -r
您的输出没有&#34;#34;开始&#34;使用pro_store
,但有多个空格,然后 pro_store
。这就是[:space:]*
添加到正则表达式的原因。