# The Silver Searcher

> High-performance code search tool, faster alternative to ack with git ignore support and parallel processing

Stars: 27.1k · Language: C · License: Apache-2.0 · Categories: Search

- Repository: https://github.com/ggreer/the_silver_searcher
- Website: http://geoff.greer.fm/ag/
- Page: https://www.trmn.sh/tools/ag

## Install

- Homebrew: `brew install the_silver_searcher`
- APT: `apt-get install silversearcher-ag`
- DNF: `dnf install the_silver_searcher`

## Overview

The Silver Searcher (ag) is a code search tool designed as a faster alternative to ack. It searches through codebases with significantly improved performance, achieving speeds up to 34x faster than ack in benchmarks. The tool automatically respects `.gitignore` and `.hgignore` patterns, and supports custom `.ignore` files for excluding specific file patterns from searches.

The performance improvements come from several technical optimizations: multithreaded searching using Pthreads to leverage multiple CPU cores, memory-mapped file reading instead of buffering, Boyer-Moore string search algorithm for literal matches, and PCRE JIT compilation for regex searches. It also pre-compiles regex patterns and uses binary search for ignore patterns rather than calling fnmatch() repeatedly.

Primary users are developers and anyone working with large codebases who need fast text searching. The tool integrates well with popular editors including Vim (via ack.vim plugin), Emacs (ag.el), and TextMate. It's available across all major platforms and can be installed through standard package managers. The command name 'ag' provides a shorter alternative to 'ack' while maintaining similar functionality and command-line interface patterns.

### Installation

```bash
# via Homebrew
brew install the_silver_searcher
```

```bash
# via APT
apt-get install silversearcher-ag
```

```bash
# via DNF
dnf install the_silver_searcher
```

## Alternatives

- [ast-grep](https://www.trmn.sh/tools/ast-grep.md): CLI for structural code search, lint, and rewriting that matches tree-sitter AST nodes using patterns written as ordinary code. Written in Rust. (Rust, 16.4k stars)
- [Maigret](https://www.trmn.sh/tools/maigret.md): OSINT CLI that searches about 5,900 sites for accounts by username and extracts profile data into reports, with no API keys required. (Python, 39.6k stars)
- [howdoi](https://www.trmn.sh/tools/howdoi.md): Command-line tool that provides instant coding answers by querying Stack Overflow without opening a browser. (Python, 10.8k stars)
- [rga](https://www.trmn.sh/tools/rga.md): Line-oriented search tool that extends ripgrep to search inside PDFs, archives, documents, and multimedia files (Rust, 9.9k stars)
- [fd](https://www.trmn.sh/tools/fd.md): Fast filesystem search tool that replaces find with regex patterns and smart defaults (Rust, 44.9k stars)

## Guides

- [Modern Replacements for grep](https://www.trmn.sh/replace/grep): Compare ripgrep, The Silver Searcher (ag) and rga as replacements for grep: defaults, file-type handling, and what each searches.
- [ripgrep vs The Silver Searcher](https://www.trmn.sh/compare/ripgrep-vs-ag): ripgrep vs The Silver Searcher (ag): Rust vs C, ignore-file handling, regex engines, encodings, editor plugins and when to pick each.

---

Canonical: https://www.trmn.sh/tools/ag
