LinuxCommandLibrary

ugrep

Search files using flexible pattern matching

TLDR

Start a query TUI to search files in the current directory recursively ( for help)

$ ugrep [[-Q|--query]]
copy

Search the current directory recursively for files containing a regex search pattern
$ ugrep "[search_pattern]"
copy

Search in a specific file or in all files in a specific directory, showing line numbers of matches
$ ugrep [[-n|--line-number]] "[search_pattern]" [path/to/file_or_directory]
copy

Search in all files in the current directory recursively and print the name of each matching file
$ ugrep [[-l|--files-with-matches]] "[search_pattern]"
copy

Fuzzy search files with up to 3 extra, missing or mismatching characters in the pattern
$ ugrep [[-Z|--fuzzy=]][3] "[search_pattern]"
copy

Also search compressed files, Zip and tar archives recursively
$ ugrep [[-z|--decompress]] "[search_pattern]"
copy

Search only files whose filenames match a specific glob pattern
$ ugrep [[-g |--glob=]]"[glob_pattern]" "[search_pattern]"
copy

Search only C++ source files (use --file-type=list to list all file types)
$ ugrep [[-t |--file-type=]]cpp "[search_pattern]"
copy

SYNOPSIS

ugrep [OPTIONS] PATTERN [FILE...]

PARAMETERS

-i, --ignore-case
    Ignore case distinctions in both the PATTERN and the input files.

-r, --recursive
    Recursively search directories.

-l, --files-with-matches
    Only print the names of files containing matches.

-v, --invert-match
    Select non-matching lines.

-c, --count
    Only print a count of matching lines per file.

-n, --line-number
    Prefix each line of output with the line number within its input file.

-o, --only-matching
    Show only the part of a matching line that matches PATTERN.

-H, --with-filename
    Print the file name for each match.

-h, --no-filename
    Suppress the prefixing of file names on output.

-w, --word-regexp
    Select only those lines containing matches that form whole words.

-x, --line-regexp
    Select only those matches that exactly match the whole line.

-q, --quiet, --silent
    Suppress all normal output.

-z, --null-data
    A data line ends in 0 byte, not newline.

--help
    Display help message and exit.

--version
    Output version information and exit.

DESCRIPTION

ugrep is a fast, user-friendly, and compatible grep replacement. It aims to be significantly faster than GNU grep, especially on large files or directories. It supports common grep features like regular expressions, recursive directory searching, and various output formats, but also offers improvements like more intelligent search heuristics, better support for Unicode, and easier configuration.

It is designed to be a drop-in replacement in many cases, but be aware that it is not perfect, for some edge cases might produce different results. In order to check that it works as intended, ugrep provides several tools for testing. It also intends to offer a more modern and intuitive interface than standard grep.

CAVEATS

While ugrep strives for compatibility, subtle differences in regular expression handling or default behavior might exist compared to GNU grep. Always test thoroughly when replacing grep in critical scripts.

Performance may vary depending on the specific pattern, input data, and hardware.

REGULAR EXPRESSION SYNTAX

ugrep supports a variety of regular expression syntaxes.
The most common is the POSIX extended regular expression (ERE) syntax by default, unless other syntax is specified using options.

EXIT STATUS

The exit status is 0 if selected lines are found, and 1 if not found. If an error occurred the exit status is 2.

HISTORY

ugrep is a relatively new command-line tool focused on performance and user experience. Development is active, with frequent updates and improvements. It's designed to address performance bottlenecks often encountered with GNU grep, especially when processing large datasets. Its intention is to be a modern solution to the 'grep' functionality, trying to provide a faster alternative.

SEE ALSO

grep(1), awk(1), sed(1), find(1)

Copied to clipboard