Home Linux Commandline Tools Ripgrep – The Fastest Command Line Search Tool for Linux

Ripgrep – The Fastest Command Line Search Tool for Linux

As the Linux operating system grows on you, you start being labeled the nerd you always wanted to be. Your behavior in this operating system environment changes completely. You develop a superiority complex that transforms you from a GUI-oriented user to a terminal-based user. You want to achieve a lot of things without switching between interfaces.

ripgrep is one such tool that adaptively keeps a Linux user objectified and bound to the command line interface. It effortlessly achieves line-oriented recursive searches for a Linux user by adhering to regex pattern rules.

The user in question has to be on the same command-line directory path with the targeted files or folders. The default makeup of this ripgrep tool makes it sync with gitignore rules. It is an advantage to Linux users that have a bond with the metrics of the Github repositories. In this case, the recursive searches results will not consider binary files and hidden files/directories.

ripgrep shares a DNA footprint with popular search tools like grep, find, ack, and The Silver Searcher.

How to Install Ripgrep in Linux

Before we proceed with ripgrep’s installation guide, it is important that you familiarize yourself with this line-oriented recursive search tool’s binary name i.e rg. Its precompiled archived binaries are available for the Linux OS distributions and are static executables.

$ sudo apt-get install ripgrep   [On Debian/Ubuntu & Mint] 
$ pacman -S ripgrep              [On Arch Linux]
$ emerge sys-apps/ripgrep        [On Gentoo]
$ sudo dnf install ripgrep       [On Fedora]
$ sudo zypper install ripgrep    [On openSUSE]
$ pkg install ripgrep            [On FreeBSD]
$ doas pkg_add ripgrep           [On OpenBSD]
$ pkgin install ripgrep          [On NetBSD]

------ On RHEL/CentOS and Rocky Linux/Alma Linux ------ 
$ sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo
$ sudo yum install ripgrep

How to Use Ripgrep in Linux

In this section, we are going to acknowledge some outstanding capabilities of ripgrep through specific elementary descriptions. This section of the article assumes that you already have ripgrep installed and you have some familiarity with the Linux command-line interface.

Ripgrep Command Examples

Assuming that you are in your downloads directory, you could search for the occurrence of the word documentation in any file and ripgrep will point out those files.

$ rg documentation
Search for Word in Files
Search for Word in Files

You could also search for a specific word occurrence in a file.

$ rg 'question' LinuxShellTips.md
Search for Specific Word in File
Search for Specific Word in File

Case Insensitive Search

When searching for a pattern, ignore case differences. For example, the following command matches questioner, Questioner, QUESTIONER, etc.

$ rg -i 'questioner' LinuxShellTips.txt
Ignore Case Sensitive Search in Linux
Ignore Case Sensitive Search in Linux

Limiting Output Lines

Limit the length of lines printed by ripgrep.

$ rg -m2 'in' LinuxShellTips.txt
$ seq 10 | rg -m4 '2'
Limit Length of Lines in Linux
Limit Length of Lines in Linux

Multiple Search Strings

Search for multiple words in the file.

$ rg -e 'user' -e '8' LinuxShellTips.txt
Search Multiple Words in Linux
Search Multiple Words in Linux

Find Files Containing Specific Text in Linux

In this example, search for a word called 'questioner' in all files under the present working directory.

$ rg -l 'questioner' 
Find Files Containing Specific Word in Linux
Find Files Containing Specific Word in Linux

If you are thinking of further exploring the usage of this ripgrep search tool, consider referencing the following terminal commands for its documentation and syntax usage.

$ man rg
Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

3 thoughts on “Ripgrep – The Fastest Command Line Search Tool for Linux”

    • @Alvaro,

      The main difference is that ripgrep is faster than grep and most of grep’s features are implemented in ripgrep. They include full Unicode support, color highlighting on search matches, multiple patterns searches, and search results context display.

      Reply
    • ripgrep author here. The main user-facing difference is that ripgrep will automatically skip searching certain files: files in your gitignore, hidden files, and binary files. grep will by default try to search everything.

      The primary reason for this isn’t necessarily performance, although it does occasionally help with that. The primary reason is to improve the signal-to-noise ratio of results. Of course, ‘rg -uuu …‘ can be used, and this will disable all such “smart” filtering.

      Reply

Leave a Reply to Ravi Saive Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.