• 文件内容极速搜索工具: 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
    
  • 相关阅读:
    【三】shiro入门 之 Realm
    【一】shiro入门 之 Shiro简介
    【二】shiro入门 之 身份验证
    [01] radio ,checkbox 表单文字对齐
    [02]时区时间获取
    【14】redux 之 redux-actions
    【02】webpack 之 入门
    【13】react 之 redux(2)
    【12】react 之 redux(1)
    【11】react 之 flux
  • 原文地址:https://www.cnblogs.com/yldf/p/11900015.html
Copyright © 2020-2023  润新知