ugrep: A Faster grep That Actually Stays Compatible
You've probably been told a dozen times that some new tool is a "grep replacement," only to find it uses a different regex engine and breaks half your scripts. If you've ever symlinked one of those alternatives to grep and watched things fall apart, you know the frustration. ugrep takes a different approach: it's built to be a genuine drop-in replacement for BSD and GNU grep, while being faster and adding a long list of features the original never had.
What It Does
ugrep is a file pattern searcher written to be compatible with GNU and BSD grep. The README is explicit about what that compatibility means: you can copy or symlink ug to grep, egrep, and fgrep, and it'll behave like the tool you expect. That's a meaningful distinction from other "grep alternatives," which the README calls out for implementing incompatible command-line options and using a Perl-only regex matcher. ugrep supports POSIX BRE and ERE in addition to full Unicode extended regex, so all the regex modes your existing commands rely on are still there.
Beyond compatibility, ugrep ships a fairly wide feature set. It matches Unicode patterns by default and automatically detects UTF-8, UTF-16, and UTF-32 encoded files. It matches across multiple lines using or \R in your patterns with no special flags. It can search inside nested zip, 7z, tar, pax, and cpio archives, plus compressed files in gz, Z, bz, bz2, lzma, xz, lz4, zstd, and brotli formats. There's support for searching binary files and hexdumps, searching documents like PDF and doc/docx, and outputting results as JSON, XML, CSV, or a custom format. There's also a separate file indexer for speeding up searches on slow or cold file systems.
Why It's Cool
-
The compatibility claim is the real selling point. Plenty of tools say they're grep replacements, but ugrep actually lets you symlink it to
grepand keep your existing scripts working. It supports POSIX BRE and ERE and Unicode extended regex, which is more than the Perl-only alternatives offer. If you've been burned by a "replacement" that broke your patterns, this matters. -
Multi-line matching with zero ceremony. Using
or\Rin a pattern just works, no special options needed. That's a small thing on paper, but it removes a whole class of awkward workarounds. -
The interactive mode is genuinely different. Running
ug -Qopens a query TUI that searches files as you type, with F1 or CTRL-Z for help and TAB/SHIFT-TAB to navigate directories and files. It's a mode of working that grep has never offered, and it's the kind of thing you'd otherwise reach for a separate tool to do. -
Configuration that remembers. The
ugcommand loads an optional.ugrepconfig file from your working or home directory, andug --save-configwrites your preferred options to disk so you don't retype them. Meanwhileugrepruns like plain GNU grep without the config, so interactive and batch use stay separate. That's a clean split. -
Built-in help that's actually targeted.
ug --help WHATshows options related to a topic —ug --help regex,ug --help globs,ug --help fuzzy,ug --help format. It's a small design choice, but it beats scrolling through a wall of flags. -
The
+variants handle documents.ug+andugrep+extend searches to PDFs, documents, e-books, and image metadata, which means one tool covers text files and the documents you'd otherwise need something else for.
The README also links to reproducible benchmarks and states that ugrep is typically faster than rg, ag, and GNU grep — worth checking yourself rather than taking on faith, but the project publishes its methodology.
How to Try It
Head to the repository for install instructions on your platform. Once it's installed, the quickest way in is:
-
Start with the interactive command:
ug PATTERNThis loads your
.ugrepconfig if you have one. If you don't, try:ug --save-config --your-preferred-optionsto create one in the current directory (or your home directory for general use).
-
For batch or scripted use, run
ugrepthe way you'd run GNU grep:ugrep PATTERN files... -
Explore the TUI by running
ug -Qand pressing F1 for help. -
Check the User Guide and the indexing repo if you want to speed up searches on slow file systems.
Final Thoughts
ugrep is aimed at people who live in the terminal and want their grep commands to keep working while getting more out of them. The compatibility-first design is the honest part — it means you can adopt it incrementally, symlink it where you're confident, and fall back to ugrep for batch work. If you're happy with GNU grep and never hit multi-line patterns or archive searches, you probably don't need this. But if you've been frustrated by "alternatives" that quietly change your regex semantics, ugrep is worth a look.
Follow @githubprojects for more developer tools and open source projects.