The ugrep
tool is a faster, user-friendly and compatible grep
replacement written in C++11. Let's check how to install ugrep
and how to use the interactive query mode, fuzzy search, and other options.
What is grep
?
If you are a terminal user, grep
is a basic tool that you must learn. The grep
command is a filter that prints lines from a file that contain a match for one or more patterns.
E.g. grep
can help you to find specific output in a log file like the following:
grep 10.0.0.1 server.log
In this post we're going to focus in the ugrep
app, an extension of this tool.
Installation
In Windows, you can just download the full-featured ugrep.exe from the official repository, or use a tool like: choco install ugrep
or scoop install ugrep
.
In MacOS, you could use brew install ugrep
.
Or, find your destiny here: https://github.com/Genivia/ugrep#install.
The basics
The basic usage is start the interactive query mode and look for a specific text in recursively in sub-directories using plain-text or regex.
ugrep -Q
💡 Tip: you can add the --ignore-case
argument to make case-insensitive matches.
If you want to see only the files that contains the search term you can use the following arguments:
ugrep -Q --ignore-case --files-with-matches
The fuzzy search
The fuzzy search is the technique of look for a text that match a pattern approximately, instead of exactly. We can look for a text within the specified Levenshtein distance.
ugrep -Z3 android
💡 Tip: -Z3
matches up to three extra, missing or replaced characters; -Z+~3
allows up to three insertions (+
) or substitutions (~
), but no deletions (-
).
You can start a query mode with fuzzy search like the following:
ugrep -Q -Z3
Interactive TUI
Once you started the query mode, you can toggle fuzzy search, list only filenames, or more in options panel pressing F1
.
Press the upper case Z to toggle on/off the fuzzy search mode, and [
to increase and ]
to decrease the fuzziness.
Also, you can scroll the result of a search using the arrow keys or ^S
, then with F2
you can open the editor for the file of the current matched text (nano, vim, etc).
More ugrep
You have a lot of possible customization options you could investigate in the README or use ugrep with Vim.
Thanks to Dr. Robert van Engelen for this awesome tool! and if you 💛 it too, leave a ⭐ in https://github.com/Genivia/ugrep.
Top comments (0)