文件内容极速搜索工具: silversearcher-ag
生活随笔
收集整理的這篇文章主要介紹了
文件内容极速搜索工具: silversearcher-ag
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
參考安裝常見操作
參考
https://github.com/ggreer/the_silver_searcher
安裝
yum install epel-release.noarch the_silver_searcher -y
常見操作
ag printf
Find matches for "printf" in the current directory.
ag foo /bar/
Find matches for "foo" in path /bar/.
ag – --foo
Find matches for "--foo" in the current directory. (As with most UNIX command line utilities, "--" is used to signify that the remaining arguments should not be treated as options.)
ag -G cpio.c size
在所有文件名為 *cpio.c* 的文件中搜索字串 size. (-G --file-search-regex PATTERN, Only search files whose names match PATTERN. 幫助中出現PATTERN項就代表必須使用正則式)
ag -G cpio.c -w size
在所有文件名為 *cpio.c* 的文件中搜索單詞 size.
ag readme$
正則式搜索 readme$
ag .rb files/
在files目錄搜索含 .rb 的字串 (所有的 arb, crb 等等)
ag -Q .rb files/
在files目錄搜索含 .rb 的字串 (只匹配 .rb,相當于正則式的 .rb)
ag DHH -l
搜索含有單詞 DHH 的所有文件,且只打印處文件名
ag readme -l -G action
在所有文件名為 *action* 的文件中搜索字串 readme,且只打印處文件名
ag readme -l -G action$
在所有文件名為 *action 的文件中搜索字串 readme,且只打印處文件名
ps -e | ag forego
通過管道使用 ag
–php
只搜索php文件
ag readme -l -G action$ --pager "less -R"
在所有文件名為 *action 的文件中搜索字串 readme,且只打印處文件名,使用 less來分頁。(alias ag="ag $* --pager 'less -R'",這個可以一勞永逸)**加粗樣式**
-B2
匹配當前行與前兩行
-A2
匹配當前行與后兩行
-C2
匹配當前行以及前后2行
-w
以word為單位進行匹配
-U
忽略版本控制相關隱藏文件:比如 .gitignore .hgignore
總結
以上是生活随笔為你收集整理的文件内容极速搜索工具: silversearcher-ag的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ExtJS中如何根据combobox的选
- 下一篇: Java正則表達式詳解