LinuxCommandLibrary

xzfgrep

Search compressed files for a pattern

TLDR

View documentation for the original command

$ tldr xzgrep
copy

SYNOPSIS

xzfgrep [options] PATTERN [FILE...]

PARAMETERS

-F, --fixed-strings
    Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. This is the core functionality implied by 'fgrep'.

-i, --ignore-case
    Ignore case distinctions in PATTERN and input data.

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

-c, --count
    Suppress normal output; instead print a count of matching lines for each input file.

-l, --files-with-matches
    Suppress normal output; instead print the name of each input file from which output would normally have been printed.

-L, --files-without-match
    Suppress normal output; instead print the name of each input file from which no output would normally have been printed.

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

-H, --with-filename
    Print the file name for each match. This is the default when there is more than one file to search.

-h, --no-filename
    Suppress the prefixing of file names on output when multiple files are searched.

-q, --quiet, --silent
    Suppress all normal output. Exit immediately with zero status if any match is found, or with non-zero status otherwise.

-s, --no-messages
    Suppress error messages about non-existent or unreadable files.

--color[=WHEN]
    Use markers to highlight the matching strings. WHEN can be 'never', 'always', or 'auto'.

-A NUM, --after-context=NUM
    Print NUM lines of trailing context after matching lines.

-B NUM, --before-context=NUM
    Print NUM lines of leading context before matching lines.

-C NUM, --context=NUM
    Print NUM lines of leading and trailing context around matching lines.

DESCRIPTION

xzfgrep is not a standalone command in standard Linux distributions, but rather a conceptual combination of xzgrep and fgrep (which is equivalent to grep -F).

Conceptually, it allows users to efficiently search for fixed strings (literal text patterns, not regular expressions) within files compressed using the XZ compression algorithm, without requiring prior manual decompression. This utility is invaluable for tasks such as analyzing log files, data archives, or any text-based content stored in .xz format. It functions by transparently decompressing the input XZ files on-the-fly and then applying a fixed-string search. This approach saves disk space and simplifies workflows by enabling direct interaction with compressed data, mirroring the functionality of grep for uncompressed files.

CAVEATS

This command is not a natively compiled binary or a standard alias in typical Linux distributions. It represents the conceptual functionality achieved by using xzgrep -F. Therefore, when attempting to use "xzfgrep", one should use the equivalent xzgrep -F command instead. Its performance relies on the underlying xzcat for decompression and grep -F for searching, making it efficient but still dependent on system resources for large files. It specifically searches for fixed strings and does not interpret patterns as regular expressions.

STANDARD INPUT SUPPORT

If no FILE arguments are provided, xzfgrep would read from standard input, assuming the input stream is XZ-compressed data. This allows piping compressed data directly to the command for searching.

EXIT STATUS

The command would exit with a status of 0 if one or more lines are selected, 1 if no lines are selected, and 2 if an error occurred (e.g., inaccessible file).

HISTORY

The lineage of this conceptual command traces back to two primary tools: grep and xz. grep, a fundamental Unix utility for searching plain-text data for lines matching a regular expression, was first developed by Ken Thompson in the early 1970s. Its variant fgrep (fixed grep) was later introduced to handle literal string searches more efficiently by avoiding regular expression parsing overhead. The xz compression format and its associated utilities (like xzcat and xzgrep) emerged much later, gaining popularity for their high compression ratios and integrity checking capabilities, serving as a modern alternative to gzip and bzip2. The conceptual "xzfgrep" combines these functionalities, allowing the efficiency of fixed-string searches to be applied directly to modern XZ-compressed archives.

SEE ALSO

xzgrep(1), grep(1), fgrep(1), zgrep(1), bzgrep(1), xzcat(1)

Copied to clipboard