Forrest logo
tool overview
On this page you find all important commands for the CLI tool ag. If the command you are looking for is missing please ask our AI.

ag

The command line tool "ag" stands for "The Silver Searcher." It is a fast, highly efficient grep-like tool designed to search for specific patterns within files in a directory hierarchy.

Unlike traditional grep, ag is built to be simple, fast, and flexible. It leverage's the PCRE (Perl Compatible Regular Expressions) library for its pattern matching, which allows for powerful search expressions. It also features a lot of useful options, such as the ability to filter files by type or exclude specific directories from the search.

Ag takes advantage of parallelism by searching files concurrently, making it much faster than similar tools like grep or ack. It also skips over binary files by default for efficiency.

With ag, you can search for a specific term or regular expression pattern within a directory or recursively across multiple directories. It will display the search results with line numbers and highlight the matching patterns.

Ag is available for multiple operating systems, including Linux, macOS, and Windows. It is commonly used by developers for searching code repositories or large codebases efficiently. The tool's speed, flexibility, and ease of use make it popular among programmers and sysadmins alike.

List of commands for ag:

  • ag:tldr:2a71d ag: Find files containing "foo" in a specific directory.
    $ ag ${foo} ${path-to-directory}
    try on your machine
    explain this command
  • ag:tldr:2cbb8 ag: Find "foo" in files with a name matching "bar".
    $ ag ${foo} -G ${bar}
    try on your machine
    explain this command
  • ag:tldr:3473a ag: Find files with a name matching "foo".
    $ ag -g ${foo}
    try on your machine
    explain this command
  • ag:tldr:8e025 ag: Find files containing "FOO" case-insensitively, and print only the match, rather than the whole line.
    $ ag -i -o ${FOO}
    try on your machine
    explain this command
  • ag:tldr:b2d2b ag: Find files containing "foo", and print the line matches in context.
    $ ag ${foo}
    try on your machine
    explain this command
  • ag:tldr:f298d ag: Find files containing "foo", but only list the filenames.
    $ ag -l ${foo}
    try on your machine
    explain this command
tool overview