ripgrep 0.9.0
-SIMD -AVX
brew
Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64
A flag (perhaps --search-names-and-contents or --also-search-filenames ?) that will allow searching both file contents and file names as part of the same invocation. i.e. for the hypothetical
rg --search-names-and-contents pattern dir
the output would be the (interleaved) equivalent of
rg --files -g '*pattern*' dir
rg pattern dir
I know that rg isn't intended to be a find replacement, but I often am searching through very large dir structures for files that either contain a given string OR where their filename contains that string, and running rg twice (or rg once and fd once, which is what I currently do) on the same huge dir structure (hundreds of thousands of files) is very inefficient, and having the output not interleaved because it is generated by two commands also makes it harder to read.
I don't think this is a good fit for ripgrep. I understand the use case, but ripgrep isn't a tool for searching file names. It's a tool for searching files. For example, there are several things that aren't considered in this feature request:
-g '*pattern*' are of globs, not regexes.I've thought about this more, and I'd like to keep ripgrep focused on searching files for now.
Needing to do two searches is somewhat unfortunate, but one of those searches only needs to look at file paths, which should be much quicker to execute.
For anyone arriving here from Google, use fd instead, to search files by filename: https://github.com/sharkdp/fd
It has similar improvements to rg (e.g. automatic .gitignore exclusions)
@fregante I would have mentioned that, but note that this feature request is subtly different than just searching the contents of file names. The requested feature is to search _both_ file names _and_ file contents simultaneously for the same pattern.
Most helpful comment
For anyone arriving here from Google, use
fdinstead, to search files by filename: https://github.com/sharkdp/fdIt has similar improvements to
rg(e.g. automatic .gitignore exclusions)