Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

search for files (even inside tar/zip/7z/rar) using a SQL-WHERE filter

License

NotificationsYou must be signed in to change notification settings

laktak/zfind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zfind allows you to search for files, including insidetar,zip,7z andrar archives. It makes finding files easy with a filter syntax that is similar to an SQL-WHERE clause. This means, if you know SQL, you don't have to learn or remember any new syntax just for this tool.

Basic Usage & Examples

zfind<where> [<path>...]

Examples

#find files smaller than 10KB,in the current pathzfind 'size<10k'#find filesin the given rangein /some/pathzfind 'size between 1M and 1G' /some/path#find files modified before 2010 inside a tarzfind 'date<"2010" and archive="tar"'#find files named foo* and modified todayzfind 'name like "foo%" and date=today'#find files that contain two dashes using a regexzfind 'name rlike "(.*-){2}"'#find files that have the extension .jpg or .jpegzfind 'ext in ("jpg","jpeg")'#find directories named foo and barzfind 'name in ("foo", "bar") and type="dir"'#searchforall README.md files and showin long listing formatzfind 'name="README.md"' -l#show resultsin csv formatzfind --csvzfind --csv-no-head

Where Syntax

  • AND,OR and() parentheses are logical operators used to combine multiple conditions.AND means that both conditions must be true for a row to be included in the results.OR means that if either condition is true, the row will be included. Parentheses are used to group conditions, just like in mathematics.

Example:'(size > 20M OR name = "temp") AND type="file"' selects all files that are either greater than 20 MB in size or are named temp.

  • Operators=,<>,!=,<,>,<=,>= are comparison operators used to compare values and file properties. The types must match, meaning don't compare a date to a file size.

Example:'date > "2020-10-01"' selects all files that were modified after the specified date.

  • LIKE,ILIKE andRLIKE are used for pattern matching in strings.
    • LIKE is case-sensitive, whileILIKE is case-insensitive.
    • The% symbol is used as a wildcard character that matches any sequence of characters.
    • The_ symbol matches any single character.
    • RLIKE allows matching a regular expression.

Example:'"name like "z%"' selects all files whose name starts with 'z'.

  • IN allows you to specify multiple values to match. A file will be included if the value of the property matches any of the values in the list.

Example:'"type in ("file", "link")' selects all files of type file or link.

  • BETWEEN selects values within a given range (inclusive).

Example:'"date between "2010" and "2011-01-15"' means that all files that were modified from 2010 to 2011-01-15 will be included.

  • NOT is a logical operator used to negate a condition. It returns true if the condition is false and vice versa.

Example:'"name not like "z%"','"date not between "2010" and "2011-01-15"','"type not in ("file", "link")'

  • Values can be numbers, text, date and time,TRUE andFALSE
    • dates have to be specified inYYYY-MM-DD format
    • times have to be specified in 24hHH:MM:SS format
    • numbers can be written as sizes by appendingB,K,M,G andT to specify bytes, KB, MB, GB, and TB.
    • empty strings and0 evaluate tofalse

Properties

The following file properties are available:

namedescription
namename of the file
pathfull path of the file
containerpath of the container (if inside an archive)
sizefile size (uncompressed)
datemodified date in YYYY-MM-DD format
timemodified time in HH-MM-SS format
extshort file extension (e.g.,txt)
ext2long file extension (two parts, e.g.,tar.gz)
typefile,dir, orlink
archivearchive type:tar,zip,7z,rar or empty

Helper properties

namedescription
todaytoday's date
molast monday's date
tulast tuesday's date
welast wednesday's date
thlast thursday's date
frlast friday's date
salast saturday's date
sulast sunday's date

Supported archives

nameextensions
tar.tar,.tar.gz,.tgz,.tar.bz2,.tbz2,.tar.xz,.txz
zip.zip
7zip.7z
rar.rar

Note: use the flag -n (or --no-archive) to disable archive support. You can also use'not archive' in your query but this still requires zfind to open the archive.

Actions

zfind does not implement actions likefind, instead usexargs -0 to execute commands:

zfind --no-archive'name like "%.txt"' -0| xargs -0 -L1echo

zfind can also produce--csv (or--csv-no-head) that can be piped to other commands.

Configuration

Set the environment variableNO_COLOR to disable color output.

Installation

Binary releases

You can download the official zfind binaries from the releases page and place it in yourPATH.

Prereleased versions can be found directly on theGitHub Action. Click on the latestci action and look forprerelease-artifacts at the bottom.

Homebrew (macOS and Linux)

For macOS and Linux it can also be installed viaHomebrew:

brew install zfind

Arch Linux

zfind is available in the AUR aszfind:

paru -S zfind

Build from Source

Building from the source requires Go.

  • Either install it directly
go install github.com/laktak/zfind/cmd/zfind@latest
  • or clone and build
git clone https://github.com/laktak/zfindzfind/scripts/build# output is here:zfind/zfind

zfind as a Go module

zfind is can also be used in other Go programs.

go get github.com/laktak/zfind

The library consists of two main packages:

  • filter: provides functionality for parsing and evaluating SQL-where filter expressions
  • find: implements searching for files and directories.

For more information see the linked documentation on pkg.go.dev.

About

search for files (even inside tar/zip/7z/rar) using a SQL-WHERE filter

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

[8]ページ先頭

©2009-2025 Movatter.jp