ztgrep

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

README

ztgrep

GoDoc

Search for file names and contents within nested compressed archives.

Useful for locating data lost within many levels of compressed archives without using additional storage.

Supports the following compression formats for both archives and files:

  • gzip
  • bzip2
  • xz (requires xz-utils with xz CLI on $PATH)
  • zstd (requires zstd with zstd CLI on $PATH)
  • uncompressed

As well as the following archive formats:

  • Tar (V7, USTAR, PAX, GNU, STAR)
  • ZIP (with size limitation)

Nested archives and compressed files must have a recognizable file extension to be searched.

If multiple paths are specified, they are searched in parallel with nondeterministic output order. However, output order is deterministic for any single path. Only one path per CPU is searched concurrently.

Nested ZIP files must be read into memory to be searched. By default, ZIP files larger 10 MB are not searched. The -z option may be used to specify this size limit.

Usage:
  ztgrep [OPTIONS] regexp paths...

Search Options:
  -b, --skip-body     Skip file bodies
  -n, --skip-name     Skip file names inside of tarballs
  -z, --max-zip-size= Maximum zip file size to search in bytes (default: 10 MB)

General Options:
  -v, --version       Return ztgrep version

Help Options:
  -h, --help          Show this help message
Installation

Binaries for macOS, Linux, and Windows are attached to each release.

ztgrep is also available as a Docker image.

Go Package

ztgrep may be imported as a Go package. See godoc for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Path []string
	Err  error
}

Result contains each matching path in Path. Each entry in Path[1:] represents a file nested in the previous archive.

type ZTgrep

type ZTgrep struct {
	MaxZipSize int64 // maximum size of zip file to search (held in memory)
	SkipName   bool  // skip file names
	SkipBody   bool  // skip file contents
	// contains filtered or unexported fields
}

ZTgrep searchs for file names and contents within nested compressed archives.

func New

func New(expr string) (*ZTgrep, error)

New returns a *ZTgrep given a regular expression following https://golang.org/s/re2syntax

func (*ZTgrep) Start

func (zt *ZTgrep) Start(paths []string) <-chan Result

Start searches paths in parallel, returning results via a channel

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL