ripgrep [Fast grep with better defaults and customization]

Submit command line tools that you find here.
Post Reply
Message
Author
User avatar
vevy
Posts: 752
Joined: Tue Sep 10, 2019 11:17 am

ripgrep [Fast grep with better defaults and customization]

#1 Post by vevy » Sun Nov 08, 2020 7:10 am

Since grep tools are all the rage! :P I thought I'd add a very good one that hasn't been mentioned once in the forums!


https://github.com/BurntSushi/ripgrep
"ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern. By default, ripgrep will respect your .gitignore and automatically skip hidden files/directories and binary files. ripgrep has first class support on Windows, macOS and Linux, with binary downloads available for every release. ripgrep is similar to other popular search tools like The Silver Searcher, ack and grep."
Image


Is it really faster than everything else?

Generally, yes. A large number of benchmarks with detailed analysis for each is available on my blog.
Why should I use ripgrep?
  • It can replace many use cases served by other search tools because it contains most of their features and is generally faster. (See the FAQ for more details on whether ripgrep can truly replace grep.)
  • Like other tools specialized to code search, ripgrep defaults to recursive directory search and won't search files ignored by your .gitignore/.ignore/.rgignore files. It also ignores hidden and binary files by default. ripgrep also implements full support for .gitignore, whereas there are many bugs related to that functionality in other code search tools claiming to provide the same functionality.
  • ripgrep can search specific types of files. For example, rg -tpy foo limits your search to Python files and rg -Tjs foo excludes JavaScript files from your search. ripgrep can be taught about new file types with custom matching rules.
  • ripgrep supports many features found in grep, such as showing the context of search results, searching multiple patterns, highlighting matches with color and full Unicode support. Unlike GNU grep, ripgrep stays fast while supporting Unicode (which is always on).
  • ripgrep has optional support for switching its regex engine to use PCRE2. Among other things, this makes it possible to use look-around and backreferences in your patterns, which are not supported in ripgrep's default regex engine. PCRE2 support can be enabled with -P/--pcre2 (use PCRE2 always) or --auto-hybrid-regex (use PCRE2 only if needed). An alternative syntax is provided via the --engine (default|pcre2|auto-hybrid) option.
  • ripgrep supports searching files in text encodings other than UTF-8, such as UTF-16, latin-1, GBK, EUC-JP, Shift_JIS and more. (Some support for automatically detecting UTF-16 is provided. Other text encodings must be specifically specified with the -E/--encoding flag.)
  • ripgrep supports searching files compressed in a common format (brotli, bzip2, gzip, lz4, lzma, xz, or zstandard) with the -z/--search-zip flag.
  • ripgrep supports arbitrary input preprocessing filters which could be PDF text extraction, less supported decompression, decrypting, automatic encoding detection and so on.
In other words, use ripgrep if you like speed, filtering by default, fewer bugs and Unicode support.
Portable by default (no settings, bu can can accept config files and pattern files).
It is also really customizable in options and looks (of results).

The developer doesn't accept donations!
Last edited by vevy on Sun Nov 08, 2020 7:29 am, edited 3 times in total.
Help make the comprehensive CLI database happen:
                    Vote for filters/badges!

User avatar
vevy
Posts: 752
Joined: Tue Sep 10, 2019 11:17 am

Re: ripgrep [Fast grep with better defaults and customization]

#2 Post by vevy » Sun Nov 08, 2020 7:16 am

A comparison:
Please remember that a single benchmark is never enough! See my blog post on ripgrep for a very detailed comparison with more benchmarks and analysis.
Tool Command Line count Time
ripgrep (Unicode) rg -n -w '[A-Z]+_SUSPEND' 452 0.136s
git grep git grep -P -n -w '[A-Z]+_SUSPEND' 452 0.348s
ugrep (Unicode) ugrep -r --ignore-files --no-hidden -I -w '[A-Z]+_SUSPEND' 452 0.506s
The Silver Searcher ag -w '[A-Z]+_SUSPEND' 452 0.654s
git grep LC_ALL=C git grep -E -n -w '[A-Z]+_SUSPEND' 452 1.150s
ack ack -w '[A-Z]+_SUSPEND' 452 4.054s
git grep (Unicode) LC_ALL=en_US.UTF-8 git grep -E -n -w '[A-Z]+_SUSPEND' 452 4.205s



There is also rga: https://github.com/phiresky/ripgrep-all
rga: ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
Help make the comprehensive CLI database happen:
                    Vote for filters/badges!

rbon
Posts: 249
Joined: Wed Mar 28, 2007 2:16 am
Location: Italy

Re: ripgrep [Fast grep with better defaults and customization]

#3 Post by rbon » Sun Nov 08, 2020 11:26 am

Some details about ripgrep:
• ripgrep corrent release: 12.1.1
• ripgrep GitHub download page: https://github.com/BurntSushi/ripgrep/r ... tag/12.1.1
• direct download archive 'ripgrep-12.1.1-x86_64-pc-windows-msvc.zip': https://github.com/BurntSushi/ripgrep/r ... s-msvc.zip
• direct download archive 'ripgrep-12.1.1-x86_64-pc-windows-gnu.zip': https://github.com/BurntSushi/ripgrep/r ... ws-gnu.zip

Archive sizes:
• Microsoft Visual C++: 1.75 MB
• GNU MinGW: 9.08 MB
MinGW archive do not require runtime.

Note
Windows binaries are available either as built with MinGW (GNU) or with Microsoft Visual C++ (MSVC). When possible, prefer MSVC over GNU, but you'll need to have the Microsoft VC++ 2015 redistributable installed.*
* Latest supported Visual C++ downloads are: 'Visual Studio 2015, 2017 and 2019'
• Microsoft download page: https://support.microsoft.com/en-us/hel ... -downloads
• Softpedia: https://www.softpedia.com/get/Programmi ... 2017.shtml

User avatar
vevy
Posts: 752
Joined: Tue Sep 10, 2019 11:17 am

Re: ripgrep [Fast grep with better defaults and customization]

#4 Post by vevy » Tue Nov 10, 2020 3:00 pm

Thanks for the info, rbon!
Help make the comprehensive CLI database happen:
                    Vote for filters/badges!

User avatar
webfork
Posts: 9656
Joined: Wed Apr 11, 2007 8:06 pm
Location: US, Texas
Contact:

Re: ripgrep [Fast grep with better defaults and customization]

#5 Post by webfork » Fri Dec 04, 2020 4:32 pm

Another welcome addition to ripgrep: rga

ripgrep, but also search in PDFs, E-Books, Office documents, zip, tar.gz, etc.
https://phiresky.github.io/blog/2019/rg ... -epub-jpg/
rga is a line-oriented search tool that allows you to look for a regex in a multitude of file types. rga wraps the awesome ripgrep and enables it to search in pdf, docx, sqlite, jpg, zip, tar.*, movie subtitles (mkv, mp4), etc.

Post Reply