snippetbashTip
ag — The Silver Searcher. Like `ack`, but aims to be faster. More information: <https://manned.org/ag>.
Viewed 0 times
thesearchercommandsilverackaglikecli
Problem
How to use the
ag command: The Silver Searcher. Like ack, but aims to be faster. More information: <https://manned.org/ag>.Solution
ag — The Silver Searcher. Like ack, but aims to be faster. More information: <https://manned.org/ag>.Find files containing
string, and print the line matches in context:ag stringFind files containing
string in a specific directory:ag string {{path/to/directory}}Find files containing
string, but only list the filenames:ag {{[-l|--files-with-matches]}} stringFind files containing
STRING case-insensitively, and print only the match, rather than the whole line:ag {{[-i|--ignore-case]}} {{[-o|--only-matching]}} STRINGFind
string in files with a name matching file_name:ag string {{[-G|--file-search-regex]}} file_nameFind files whose contents match a
regex:ag '{{^ca(t|r)$}}'Find files with a name matching
string:ag {{[-g|--filename-pattern]}} stringCode Snippets
Find files containing `string`, and print the line matches in context
ag stringFind files containing `string` in a specific directory
ag string {{path/to/directory}}Find files containing `string`, but only list the filenames
ag {{[-l|--files-with-matches]}} stringFind files containing `STRING` case-insensitively, and print only the match, rather than the whole line
ag {{[-i|--ignore-case]}} {{[-o|--only-matching]}} STRINGFind `string` in files with a name matching `file_name`
ag string {{[-G|--file-search-regex]}} file_nameContext
tldr-pages: common/ag
Revisions (0)
No revisions yet.