full-text-searchag

silver_searcher (ag) with multiple search expressions?


Does silver_searcher support specifying multiple search expressions something like -e in grep?

I could not find any option in the document/help.


Solution

  • According to the documentation, it doesn't support multiple search patterns. That said, it does support using parallel, so you can fire off multiple instances of ag for a multi-search:

    echo "foo\nbar\nbaz" | parallel 'ag --parallel --color "{}" *' 
    

    The output using the --parallel switch will be filename, linenumber and match. If that's too fancy, you can always use the OR operator in your pattern search:

    ag --color "foo|bar|baz" *