HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
ggreer
the_silver_searcher
C2012–2025
ggreer / the_silver_searcher

the_silver_searcher

A code-searching tool similar to ack, but faster.

103Distinct people
128Mentions
3Explicit recommenders
27.1KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A code-searching tool similar to ack, but faster.

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

One of my favorite idioms for searching for a string: find /path -type f |xargs grep blah Has been replaced by `ag` https://github.com/ggreer/the_silver_searcher , ag is…

lazyant used a recommendation phrase. 3 indexed comments match. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 9–Nov 16 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/16/2026, 8:59:02 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year128 dated mentions

Observed mentions: 2012-04-02 00:04:29 UTC to 2025-03-11 17:00:25 UTC.

05101520252012-01-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 10 mentions; 3 submissions, 7 comments20122013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 18 mentions; 3 submissions, 15 comments2014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 20 mentions; 0 submissions, 20 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 10 mentions; 0 submissions, 10 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 25 mentions; 1 submissions, 24 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 5 mentions; 0 submissions, 5 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 8 mentions; 0 submissions, 8 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 10 mentions; 0 submissions, 10 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 9 mentions; 1 submissions, 8 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 5 mentions; 0 submissions, 5 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20122012-01-01 00:00:00 UTC2013-01-01 00:00:00 UTC1037
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC18315
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC20020
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC10010
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC25124
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC505
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC808
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC10010
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC918
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC404
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC505
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC211
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC110
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

From the project README

An excerpt from the repository, fetched Nov 12, 2026.

Read the project’s introduction
The Silver Searcher A code searching tool similar to ack, with a focus on speed. Do you know C? Want to improve ag? I invite you to pair with me. What's so great about Ag? It is an order of magnitude faster than ack. It ignores file patterns from your .gitignore and .hgignore. If there are files in your source repo you don't want to search, just add their patterns to a .ignore file. (*cough* *.min.js *cough*) The command name is 33% shorter than ack, and all keys are on the home row! Ag is quite stable now. Most changes are new features, minor bug fixes, or performance improvements. It's much faster than Ack in my benchmarks: ack test_blah ~/code/ 104.66s user 4.82s system 99% cpu 1:50.03 total ag test_blah ~/code/ 4.67s user 4.58s system 286% cpu 3.227 total Ack and Ag found the same results, but Ag was 34x faster (3.2 seconds vs 110 seconds). My ~/code directory is about 8GB. Thanks to git/hg/ignore, Ag only searched 700MB of that. There are also graphs of performance across releases. How is it so fast? Ag uses Pthreads to take advantage of multiple CPU cores and search files in parallel. Files are mmap()ed instead of read into a buffer. Literal string searching uses Boyer-Moore strstr. Regex searching uses PCRE's JIT compiler (if Ag is built with PCRE >=8.21). Ag calls pcre_study() before executing the same regex on every file. Instead of calling fnmatch() on every pattern in your ignore files, non-regex patterns are loaded into arrays and binary searched. I've written several blog posts showing how I've improved performance. These include how I added pthreads, wrote my own scandir(), benchmarked every revision to find performance regressions, and profiled with gprof and Valgrind. Installing macOS brew install the_silver_searcher or port install the_silver_searcher Linux Ubuntu >= 13.10 (Saucy) or Debian >= 8 (Jessie) apt-get install silversearcher-ag Fedora 21 and lower yum install the_silver_searcher Fedora 22+ dnf install the_silver_searcher RHEL7+ yum install epel-release.noarch the_silver_searcher Gentoo emerge -a sys-apps/the_silver_searcher Arch pacman -S the_silver_searcher Slackware sbopkg -i the_silver_searcher openSUSE zypper install the_silver_searcher CentOS yum install the_silver_searcher NixOS/Nix/Nixpkgs nix-env -iA silver-searcher SUSE Linux Enterprise: Follow these simple instructions. BSD FreeBSD pkg install the_silver_searcher OpenBSD/NetBSD pkg_add the_silver_searcher Windows Win32/64 Unofficial daily builds are available. winget winget install "The Silver Searcher" Notes: This installs a release of ag.exe optimized for Windows. winget is intended to become the default package manager client for Windows. As of June 2020, it's still in beta, and can be installed using instructions there. The setup script in the Ag's winget package installs ag.exe in the first directory that matches one of these criteria: Over a previous instance of ag.exe from the same origin found in the PATH In the directory defined in environment variable bindir_%PROCESSOR_ARCHITECTURE% In the directory defined in environment variable bindir In the directory defined in environment variable windir Chocolatey choco install ag MSYS2 pacman -S mingw-w64-{i686,x86_64}-ag Cygwin Run the relevant setup-*.exe, and select "the_silver_searcher" in the "Utils" category. Building from source Building master Install dependencies (Automake, pkg-config, PCRE, LZMA): macOS: brew install automake pkg-config pcre xz or port install automake pkgconfig pcre xz Ubuntu/Debian: apt-get install -y automake pkg-config libpcre3-dev zlib1g-dev liblzma-dev Fedora: yum -y install pkgconfig automake gcc zlib-devel pcre-devel xz-devel CentOS: yum -y groupinstall "Development Tools" yum -y install pcre-devel xz-devel zlib-devel openSUSE: zypper source-install --build-deps-only the_silver_searcher Windows: It's complicated. See this wiki page. Run the build script (which just runs aclocal, automake, etc): ./build.sh On Windows (inside an msys/MinGW shell): make -f Makefile.w32 Make install: sudo make install Building a release tarball GPG-signed releases are available here. Building release tarballs requires the same dependencies, except for automake and pkg-config. Once you've installed the dependencies, just run: ./configure make make install You may need to use sudo or run as root for the make install. Editor Integration Vim You can use Ag with ack.vim by adding the following line to your .vimrc: let g:ackprg = 'ag --nogroup --nocolor --column' or: let g:ackprg = 'ag --vimgrep' Which has the same effect but will report every match on the line. Emacs You can use ag.el as an Emacs front-end to Ag. See also: helm-ag. TextMate TextMate users can use Ag with my fork of the popular AckMate plugin, which lets you use both Ack and Ag for searching. If you already have AckMate you just want to replace Ack with Ag, move or delete "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack" and run ln -s /usr/local/bin/ag "~/Library/Application Support/TextMate/PlugIns/AckMate.tmplugin/Contents/Resources/ackmate_ack" Other stuff you might like Ack - Better than grep. Without Ack, Ag would not exist. ack.vim Exuberant Ctags - Faster than Ag, but it builds an index beforehand. Good for really big codebases. Git-grep - As fast as Ag but only works on git repos. fzf - A command-line fuzzy finder ripgrep Sack - A utility that wraps Ack and Ag. It removes a lot of repetition from searching and opening matching files.
Read the full README on GitHub

What Hacker News says

20 sources
I'm the author of ag[1]. File searching stuff interests me, so I took a look at grab. Sadly, grab only compiles on Linux right now. Some of the mmap flags and cpu_set_t aren't defined on OS X. I was curious about the performance claims, so I benchmarked grab and ag on my code directory. Times are medians of five runs. I used a Lenovo X140e running Ubuntu 14.10. It has a 160GB Intel SSD, 8GB of RAM, and an AMD A4-5000 (4 x 1.5Ghz Jaguar). ggreer@boron:~/code% du -sh . 8.3G . ggreer@boron:~/code% time ag cpu_set_t ag cpu_set_t 4.45s user 5.25s system 295% cpu 3.285 total ggreer@boron:~/code% time grab -R cpu_set_t . grab -R cpu_set_t . 13.31s user 21.67s system 35% cpu 1:38.28 total 30x faster, but these benchmarks aren't a fair fight. Ag ignores binary and hidden files by default. If I tell ag to do an unrestr
Read the rest
icted search, it's still 2x faster (43 seconds vs 98 seconds). Even with cold caches (echo 3 | sudo tee /proc/sys/vm/drop_caches between each run), ag beats grab handily: ag -u cpu_set_t 19.62s user 32.56s system 90% cpu 57.433 total grab -R cpu_set_t . 15.48s user 37.89s system 37% cpu 2:22.67 total I haven't profiled grab yet, but there's definitely some low-hanging fruit. For example, it looks like grab could get a big speedup by detecting literal patterns and using strstr() instead of a whole PCRE engine. Also, FileGrep::find is calling pthread_mutex_lock/unlock even if there are no matches to print. Adding a condition around that makes grab 1.5x faster. I'm glad I took a look at grab. Despite its shortcomings, I learned from it. I'll definitely try out a few tricks grab uses that ag doesn't, such as thread affinity. One more thing: The author of grab is right about counting newlines. It does hurt performance. Still, I enable it by default in ag. I think the tradeoff is worthwhile. 1. https://github.com/ggreer/the_silver_searcher Edit: The mutex locking change was so straightforward that I submitted a PR: https://github.com/stealth/grab/pull/2
In Grab – simple but very fast grep
Is there any take-away from this rant? I guess I could have dodged heartbleed if I'd written my own TLS library and avoided any software that depended on OpenSSL. Considering the effort involved, I think I'll take heartbleed and rotate my keys. Given the number and quality of libraries today, one should spend very little time re-inventing wheels. I say that as someone who has re-invented multiple wheels. I wrote a clone of Ack[1]. I've built distributed data stores instead of using open source solutions like Cassandra. Even in those cases, building that software was harder than I thought it would be. Existing projects have graduated from the school of hard knocks. Time has forced them to solve issues like cross-platform compatibility, documentation, and API stability. They're certainly not perfect, but unless you're a domain expert with a
Read the rest
lot of time to spend, you're not going to do better. We can only re-invent so many wheels in our limited time. If you do the math, a career consists of approximately 1 million lines of code. Almost always, that time is best spent building on top of existing software. 1. https://github.com/ggreer/the_silver_searcher
In Never Reinventing the Wheel Is Anticompetitive
I'm the guy kansface mentioned. I've spent a decent amount of time figuring out how to make my programming experience better. I've tried almost every editor out there: Vim, Emacs, Sublime Text, Textmate, Visual Studio, IntelliJ, and Atom. I've customized them all with plugins. I've even written plugins for most of them. My first editor was pico, quickly followed by Vim. My toolsmithing goes beyond editors. I've tried different keyboard layouts to improve typing speed, settling on dvorak with qwerty shortcuts. I even gave chording keyboards a shot. I built Ag[1] to search code faster.[2] I don't own a mouse. If I want to point at something, I use a trackpad. Switching to/from it is much faster than grabbing a mouse. People don't want to hear this, but I could not be as fast in Vim. Even if Vim had every feature in my current setup, it woul
Read the rest
d still be slower because Vimscript executes synchronously. Executing plugin code blocks Vim's UI. If a plugin spawns a subprocess, the UI will be blocked until it exits. With Vim, you can't start a search and examine another file while it's running. This problem can be worked-around by using multiple Vims or searching from the command line, but then you lose quick opening/replacing of results. You can also abuse certain AutoCmds and updatetime to get a sort-of working async execution, but it requires each plugin have its own event loop. I agree with kansface: Vim users may type less, but they don't move faster. I have yet to see a Vim user who has impressed me with their speed. I typically see wasted motion, waiting for commands to finish, and fixing mistakes in regexes. Even your example invocations are as good or better in Sublime Text. I want to add an extra parameter to this method I just wrote. ... I just press "f)" to jump to the closing parentheses and start adding text. That does not jump to the end of the function definition. That does a search for ) on the current line. If your cursor isn't on the right line, you're SOL. Also, ) shows up in many places. It may not be part of a function definition in the language used. In my setup, "cmd + r, up" goes to the previous function definition no matter the language. If I want to go to the end, that's ctrl + m. I want to replace everything on the current line, starting from my cursor position somewhere in the middle of that line. ... I instead just press "c$" and start adding text. For me, that's ctrl + shift + e, (start typing). Unless you have a $ key, both are three keystrokes. If you use Vim and you're happy with it, great. But I would heavily discourage anyone from switching to Vim. Editors and UIs have come a long way in the past 25 years. Even with nerdtree, YCM, and other plugins, Vim can't catch up. NeoVim looks promising, since it fixes Vim's architectural problems. 1. https://github.com/ggreer/the_silver_searcher/ 2. http://geoff.greer.fm/2011/12/27/the-silver-searcher-better-...
In Vim After 11 Years (2013)
Actually, there are big problems with strcpy_s and strcat_s. First, strcpy_s abort()s the process if there would have been an overflow, making it useless for most programs. Second, Microsoft already has a function named strcat_s, and it behaves differently than the spec. Here's VC++'s strcat_s: errno_t strcat_s( char *strDestination, size_t numberOfElements, const char *strSource ); In VC++, numberOfElements is the size of strDestination. In the C11 spec, that parameter is the maximum number of bytes to copy into strDestination. People are going to search for strcat_s docs, find the MSDN page, and write buffer overflows. If strlcpy/strlcat aren't available on a target platform, I stick them them in a util.h/util.c, wrapped in #ifndefs. Like so: https://github.com/ggreer/the_silver_searcher/commit/a43dc87.
Read the rest
In Debian is switching back to GLIBC
Good point about the warning. I'll add that. With regards to search_stream() in search.c... all I can say is that I'm sorry: https://github.com/ggreer/the_silver_searcher/blob/master/sr... I built ag for myself; both as a tool and to improve my skills profiling, benchmarking, and optimizing. Had I known how popular it would become, I would have definitely held myself to a higher standard, or any standard. Most importantly, I'd have written tests. These days, I'm busy with a startup so progress on those fronts has been slow.
In Ack is a grep-like tool, optimised for programmers
I used Ack a lot when I was coding Perl (it's been a while). After I switched to Ruby, I used rak [1], which seemed easier to use most of the time, and nearly identical. However, when you just want to find stuff fast, it's annoying to have to deal with Perl/CPAN or RVM/Rubygems, especially when the dependencies are not installed on your server/workstation. That's why I've switched to silver searcher (ag) [2], as it can be installed with any OS package manager (brew, apt, yum). [1] http://rak.rubyforge.org [2] https://github.com/ggreer/the_silver_searcher
In Ack is a grep-like tool, optimised for programmers

Showing the 15 most recent of 20 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.