Search
ag
The Silver Searcher — fast code-searching tool similar to ack and grep.
Synopsis
syntax
ag [OPTION]... PATTERN [PATH]...
Examples
Search for 'function' in source files
ag 'function' src/
List files containing FIXME
ag -l 'FIXME'
Search only .js files for require
ag -G '\.js$' 'require'
Search including hidden files
ag --hidden 'secret' .
Common options
| Flag | Description |
|---|---|
| -i | Case-insensitive |
| -l | Print filenames only |
| -c | Count matches |
| -G | Filter filenames with regex |
| --hidden | Search hidden files |
About ag
The `ag` command the Silver Searcher — fast code-searching tool similar to ack and grep. Search commands help you locate files, text patterns, and executables across the filesystem.
Efficient searching is critical when working with large codebases or troubleshooting system issues. These tools range from simple filename lookups to full regular-expression pattern matching across file contents.
The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man ag`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Search Commands
Other commands in the Search category