docs: make Chinese README the default
This commit is contained in:
@@ -1,141 +1,147 @@
|
||||
<!-- WEHUB_ZH_README -->
|
||||
> [!NOTE]
|
||||
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
|
||||
> [English](./README.en.md) · [原始项目](https://github.com/jhspetersson/fselect) · [上游 README](https://github.com/jhspetersson/fselect/blob/HEAD/README.md)
|
||||
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
|
||||
|
||||
# fselect
|
||||
Find files with SQL-like queries
|
||||
使用类 SQL 查询查找文件
|
||||
|
||||
[](https://crates.io/crates/fselect)
|
||||
[](https://github.com/jhspetersson/fselect/actions/workflows/rust.yml)
|
||||
|
||||
### Why use fselect?
|
||||
### 为何使用 fselect?
|
||||
|
||||
While it doesn't tend to fully replace traditional `find` and `ls`, **fselect** has these nice features:
|
||||
虽然它通常不会完全取代传统的 `find` 和 `ls`,但 **fselect** 具备以下优点:
|
||||
|
||||
* SQL-like (not real SQL, but highly relaxed!) grammar easily understandable by humans
|
||||
* complex queries, compare results in several directories with [subqueries](docs/usage.md#subqueries-for-in-and-exists)
|
||||
* aggregate, statistics, date, and other [functions](docs/usage.md#functions)
|
||||
* search within archives
|
||||
* `.gitignore`, `.hgignore`, and `.dockerignore` support (experimental)
|
||||
* search by width and height of images, EXIF metadata
|
||||
* search by audio metadata (MP3, FLAC, Ogg Vorbis, Opus, M4A/AAC, WAV, AIFF, APE, WavPack, Musepack, Speex)
|
||||
* search by extended file attributes, POSIX ACLs, and Linux capabilities
|
||||
* search by file hashes
|
||||
* search by MIME type
|
||||
* shortcuts to common file types
|
||||
* [interactive mode](docs/usage.md#interactive-mode)
|
||||
* support for `plocate` and `Everything` indexes for lightning-fast search
|
||||
* various output formatting (CSV, JSON, and others)
|
||||
* 类 SQL(并非真正的 SQL,但语法非常宽松!)语法,易于人类理解
|
||||
* 复杂查询,可通过 [子查询](docs/usage.md#subqueries-for-in-and-exists) 在多个目录间比较结果
|
||||
* 聚合、统计、日期及其他 [函数](docs/usage.md#functions)
|
||||
* 在压缩包内搜索
|
||||
* 支持 `.gitignore`、`.hgignore` 和 `.dockerignore`(实验性)
|
||||
* 按图片宽高、EXIF 元数据搜索
|
||||
* 按音频元数据搜索(MP3、FLAC、Ogg Vorbis、Opus、M4A/AAC、WAV、AIFF、APE、WavPack、Musepack、Speex)
|
||||
* 按扩展文件属性、POSIX ACL 及 Linux capabilities 搜索
|
||||
* 按文件哈希搜索
|
||||
* 按 MIME 类型搜索
|
||||
* 常见文件类型快捷方式
|
||||
* [交互模式](docs/usage.md#interactive-mode)
|
||||
* 支持 `plocate` 和 `Everything` 索引,实现闪电般快速搜索
|
||||
* 多种输出格式(CSV、JSON 等)
|
||||
|
||||
More is under way!
|
||||
更多功能正在开发中!
|
||||
|
||||
### Installation
|
||||
### 安装
|
||||
|
||||
#### Latest release from source
|
||||
#### 从源码安装最新版本
|
||||
|
||||
* Install [Rust with Cargo](https://www.rust-lang.org/en-US/install.html) and its dependencies to build a binary
|
||||
* Run `cargo install fselect`
|
||||
* 安装 [Rust 与 Cargo](https://www.rust-lang.org/en-US/install.html) 及其依赖以构建二进制文件
|
||||
* 运行 `cargo install fselect`
|
||||
|
||||
You can optionally build with fast, index-backed search support: [voidtools *Everything*](https://www.voidtools.com/)
|
||||
on Windows (`--features everything`, then pass `--everything`) or [*plocate*](https://plocate.sesse.net/)
|
||||
on Linux (`--features plocate`, then pass `--plocate`). See the
|
||||
[usage guide](docs/usage.md#index-backed-search-everything--plocate) for details.
|
||||
你可以选择构建带快速索引搜索支持的版本:[voidtools *Everything*](https://www.voidtools.com/)
|
||||
在 Windows 上(`--features everything`,然后传入 `--everything`),或 Linux 上的 [*plocate*](https://plocate.sesse.net/)
|
||||
(`--features plocate`,然后传入 `--plocate`)。详见
|
||||
[使用指南](docs/usage.md#index-backed-search-everything--plocate)。
|
||||
|
||||
#### Debian/Ubuntu
|
||||
|
||||
[deb package](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect_0.10.2-1_amd64.deb)
|
||||
[deb 软件包](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect_0.10.2-1_amd64.deb)
|
||||
|
||||
#### Fedora/RHEL/openSUSE
|
||||
|
||||
[rpm package](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-0.10.2-1.x86_64.rpm)
|
||||
[rpm 软件包](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-0.10.2-1.x86_64.rpm)
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
[AUR package](https://aur.archlinux.org/packages/fselect/), thanks to [@asm0dey](https://github.com/asm0dey)
|
||||
[AUR 软件包](https://aur.archlinux.org/packages/fselect/),,感谢 [@asm0dey](https://github.com/asm0dey)
|
||||
|
||||
[AUR bin package](https://aur.archlinux.org/packages/fselect-bin/), thanks to [@4censord](https://github.com/4censord)
|
||||
[AUR bin 软件包](https://aur.archlinux.org/packages/fselect-bin/),,感谢 [@4censord](https://github.com/4censord)
|
||||
|
||||
#### NixOS
|
||||
|
||||
[`fselect` in `nixpkgs`](https://github.com/filalex77/nixpkgs/blob/1eced92263395896c10cea69e5f60e8be5f43aeb/pkgs/tools/misc/fselect/default.nix), thanks to [@filalex77](https://github.com/filalex77)
|
||||
[`fselect` in `nixpkgs`](https://github.com/filalex77/nixpkgs/blob/1eced92263395896c10cea69e5f60e8be5f43aeb/pkgs/tools/misc/fselect/default.nix),,感谢 [@filalex77](https://github.com/filalex77)
|
||||
|
||||
#### Other Linux
|
||||
#### 其他 Linux 发行版
|
||||
|
||||
* x86_64: [glibc](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-linux.gz) · [musl (static)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-linux-musl.gz)
|
||||
* aarch64: [glibc](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-aarch64-linux.gz) · [musl (static)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-aarch64-linux-musl.gz)
|
||||
* x86_64:[glibc](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-linux.gz) · [musl(静态)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-linux-musl.gz)
|
||||
* aarch64:[glibc](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-aarch64-linux.gz) · [musl(静态)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-aarch64-linux-musl.gz)
|
||||
|
||||
#### Windows 64bit
|
||||
#### Windows 64 位
|
||||
|
||||
A precompiled [binary](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-win.zip)
|
||||
提供预编译 [二进制文件](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-win.zip)
|
||||
|
||||
#### Windows via winget
|
||||
#### 通过 winget 在 Windows 上安装
|
||||
|
||||
* Install [winget](https://github.com/microsoft/winget-cli)
|
||||
* Run `winget install -e --id fselect.fselect`
|
||||
* 安装 [winget](https://github.com/microsoft/winget-cli)
|
||||
* 运行 `winget install -e --id fselect.fselect`
|
||||
|
||||
#### Windows via Chocolatey
|
||||
#### 通过 Chocolatey 在 Windows 上安装
|
||||
|
||||
* Install [Chocolatey](https://chocolatey.org/install)
|
||||
* Run `choco install fselect`
|
||||
* 安装 [Chocolatey](https://chocolatey.org/install)
|
||||
* 运行 `choco install fselect`
|
||||
|
||||
#### Windows via Scoop
|
||||
#### 通过 Scoop 在 Windows 上安装
|
||||
|
||||
* Install [Scoop](https://scoop.sh)
|
||||
* Run `scoop install fselect`
|
||||
* 安装 [Scoop](https://scoop.sh)
|
||||
* 运行 `scoop install fselect`
|
||||
|
||||
#### macOS
|
||||
|
||||
Precompiled binaries are available at GitHub downloads (`gunzip`, then `chmod +x fselect`):
|
||||
预编译二进制文件可在 GitHub 下载页面获取(`gunzip`,然后 `chmod +x fselect`):
|
||||
|
||||
* [Intel (x86_64)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-mac.gz)
|
||||
* [Apple Silicon (aarch64)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-aarch64-mac.gz)
|
||||
* [Intel(x86_64)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-x86_64-mac.gz)
|
||||
* [Apple Silicon(aarch64)](https://github.com/jhspetersson/fselect/releases/download/0.10.2/fselect-aarch64-mac.gz)
|
||||
|
||||
#### Mac via Homebrew
|
||||
#### 通过 Homebrew 在 Mac 上安装
|
||||
|
||||
* Install [brew](https://brew.sh)
|
||||
* Run `brew install fselect`
|
||||
* 安装 [brew](https://brew.sh)
|
||||
* 运行 `brew install fselect`
|
||||
|
||||
#### Mac via MacPorts
|
||||
#### 通过 MacPorts 在 Mac 上安装
|
||||
|
||||
* Install [MacPorts](https://www.macports.org)
|
||||
* Run:
|
||||
* 安装 [MacPorts](https://www.macports.org)
|
||||
* 运行:
|
||||
```
|
||||
sudo port selfupdate
|
||||
sudo port install fselect
|
||||
```
|
||||
|
||||
### Usage
|
||||
### 用法
|
||||
|
||||
fselect [ARGS] COLUMN[, COLUMN...] [from ROOT[, ROOT...]] [where EXPR] [group by COLUMNS] [order by COLUMNS] [limit N] [offset N] [into FORMAT]
|
||||
|
||||
### Interactive mode
|
||||
### 交互模式
|
||||
|
||||
fselect -i
|
||||
|
||||
### Documentation
|
||||
### 文档
|
||||
|
||||
[Detailed description of all the supported features.](docs/usage.md)
|
||||
[对所有支持功能的详细说明。](docs/usage.md)
|
||||
|
||||
### Examples
|
||||
### 示例
|
||||
|
||||
Find temporary or config files (full path and size):
|
||||
查找临时文件或配置文件(完整路径和大小):
|
||||
|
||||
fselect size, path from /home/user where name = '*.cfg' or name = '*.tmp'
|
||||
|
||||
Windows users may omit the quotes:
|
||||
Windows 用户可以省略引号:
|
||||
|
||||
fselect size, path from C:\Users\user where name = *.cfg or name = *.tmp
|
||||
|
||||
Or put all the arguments into the quotes like this:
|
||||
或者将所有参数放在引号中,例如:
|
||||
|
||||
fselect "name from /home/user/tmp where size > 0"
|
||||
|
||||
Search within a directory name with spaces (backticks are also supported):
|
||||
在带空格的目录名中搜索(也支持反引号):
|
||||
|
||||
fselect "name from '/home/user/dir with spaces' where size > 0"
|
||||
fselect "name from `/home/user/dir with spaces` where size > 0"
|
||||
|
||||
Or simply escape the single quote:
|
||||
或者简单地转义单引号:
|
||||
|
||||
fselect name from \'/home/user/dir with spaces\' where size gt 0
|
||||
|
||||
Specify the file size, get an absolute path, and add it to the results:
|
||||
指定文件大小,获取绝对路径并加入结果:
|
||||
|
||||
cd /home/user
|
||||
fselect size, abspath from ./tmp where size gt 2g
|
||||
@@ -143,56 +149,56 @@ Specify the file size, get an absolute path, and add it to the results:
|
||||
fselect hsize, abspath from ./tmp where size lt 8k
|
||||
fselect name, size from ./tmp where size between 5mb and 6mb
|
||||
|
||||
More complex query:
|
||||
更复杂的查询:
|
||||
|
||||
fselect "name from /tmp where (name = *.tmp and size = 0) or (name = *.cfg and size > 1000000)"
|
||||
|
||||
You can use subqueries:
|
||||
可以使用子查询:
|
||||
|
||||
fselect "name from /test1 where size > 100 and size in (select size from /test2 where name in (select name from /test3 where modified in (select modified from /test4 where size < 200)))"
|
||||
fselect "name, path, size from /data as data where exists (select * from /backup as backup where backup.name = data.name)"
|
||||
|
||||
A subquery can also be used in the `FROM` clause as the source of the outer query:
|
||||
子查询也可用于 `FROM` 子句,作为外层查询的数据源:
|
||||
|
||||
fselect "src.name, src.size from (select path from /projects depth 2 where size > 100) as src where src.name like '%.rs'"
|
||||
|
||||
Aggregate functions (you can use curly braces if you want and even combine them with the regular parentheses):
|
||||
聚合函数(可按需使用花括号,甚至可与普通圆括号组合使用):
|
||||
|
||||
fselect "MIN(size), MAX{size}, AVG(size), SUM{size}, COUNT(*) from /home/user/Downloads"
|
||||
|
||||
Formatting functions:
|
||||
格式化函数:
|
||||
|
||||
fselect "LOWER(name), UPPER(name), LENGTH(name), YEAR(modified) from /home/user/Downloads"
|
||||
|
||||
Get the year of the oldest file:
|
||||
获取最旧文件的年份:
|
||||
|
||||
fselect "MIN(YEAR(modified)) from /home/user"
|
||||
|
||||
Use single quotes if you need to address files with spaces:
|
||||
如需处理带空格的文件名,请使用单引号:
|
||||
|
||||
fselect "path from '/home/user/Misc stuff' where name != 'Some file'"
|
||||
|
||||
Regular expressions of [Rust flavor](https://docs.rs/regex/1.1.0/regex/#syntax) are supported:
|
||||
支持 [Rust 风格](https://docs.rs/regex/1.1.0/regex/#syntax) 的正则表达式:
|
||||
|
||||
fselect name from /home/user where path =~ '.*Rust.*'
|
||||
|
||||
Negate regular expressions:
|
||||
否定正则表达式:
|
||||
|
||||
fselect "name from . where path !=~ '^\./config'"
|
||||
|
||||
Simple globs expand automatically and work with `=` and `!=` operators:
|
||||
简单 glob 会自动展开,可与 `=` 和 `!=` 运算符配合使用:
|
||||
|
||||
fselect name from /home/user where path = '*Rust*'
|
||||
|
||||
Classic LIKE:
|
||||
经典 LIKE:
|
||||
|
||||
fselect "path from /home/user where name like '%report-2018-__-__???'"
|
||||
|
||||
Exact match operators to search with regexps disabled:
|
||||
精确匹配运算符,可在禁用正则表达式的情况下搜索:
|
||||
|
||||
fselect "path from /home/user where name === 'some_*_weird_*_name'"
|
||||
|
||||
Find files by date:
|
||||
按日期查找文件:
|
||||
|
||||
fselect path from /home/user where created = 2017-05-01
|
||||
fselect path from /home/user where modified = today
|
||||
@@ -200,127 +206,127 @@ Find files by date:
|
||||
fselect "path from /home/user where modified = 'apr 1'"
|
||||
fselect "path from /home/user where modified = 'last fri'"
|
||||
|
||||
Be more specific to match all files created at an interval between 3PM and 4PM:
|
||||
更精确地匹配在下午 3 点至 4 点之间创建的所有文件:
|
||||
|
||||
fselect path from /home/user where created = '2017-05-01 15'
|
||||
|
||||
And even more specific:
|
||||
还可以更精确:
|
||||
|
||||
fselect path from /home/user where created = '2017-05-01 15:10'
|
||||
fselect path from /home/user where created = '2017-05-01 15:10:30'
|
||||
|
||||
Date and time intervals are possible (find everything updated since May 1st):
|
||||
支持日期和时间区间(查找自 5 月 1 日以来更新的所有内容):
|
||||
|
||||
fselect path from /home/user where modified gte 2017-05-01
|
||||
|
||||
Default is the current directory:
|
||||
|
||||
默认为当前目录:
|
||||
|
||||
fselect path, size where name = '*.jpg'
|
||||
|
||||
Search within multiple locations:
|
||||
在多个位置中搜索:
|
||||
|
||||
fselect path from /home/user/oldstuff, /home/user/newstuff where name = '*.jpg'
|
||||
|
||||
With minimum and/or maximum depth specified (`depth` is a synonym for `maxdepth`):
|
||||
可指定最小和/或最大深度(`depth` 是 `maxdepth` 的同义词):
|
||||
|
||||
fselect path from /home/user/oldstuff depth 5 where name = '*.jpg'
|
||||
fselect path from /home/user/oldstuff mindepth 2 maxdepth 5, /home/user/newstuff depth 10 where name = '*.jpg'
|
||||
|
||||
Optionally follow symlinks:
|
||||
可选择跟随符号链接(symlinks):
|
||||
|
||||
fselect path, size from /home/user symlinks where name = '*.jpg'
|
||||
|
||||
Search within archives (currently only zip-archives are supported):
|
||||
在压缩包内搜索(目前仅支持 zip 压缩包):
|
||||
|
||||
fselect path, size from /home/user archives where name = '*.jpg'
|
||||
|
||||
Or in combination:
|
||||
或组合使用:
|
||||
|
||||
fselect size, path from /home/user depth 5 archives symlinks where name = '*.jpg' limit 100
|
||||
|
||||
Enable `.gitignore` or `.hgignore` support:
|
||||
启用 `.gitignore` 或 `.hgignore` 支持:
|
||||
|
||||
fselect size, path from /home/user/projects gitignore where name = '*.cpp'
|
||||
fselect size, path from /home/user/projects git where name = '*.cpp'
|
||||
fselect size, path from /home/user/projects hgignore where name = '*.py'
|
||||
|
||||
Search by image dimensions:
|
||||
按图像尺寸搜索:
|
||||
|
||||
fselect CONCAT(width, 'x', height), path from /home/user/photos where width gte 2000 or height gte 2000
|
||||
|
||||
Find square images:
|
||||
查找正方形图像:
|
||||
|
||||
fselect path from /home/user/Photos where width = height
|
||||
|
||||
Find images with a known name part but unknown extension:
|
||||
查找名称部分已知但扩展名未知的图像:
|
||||
|
||||
fselect path from /home/user/projects where name = "*RDS*" and width gte 1
|
||||
|
||||
Find old-school rap MP3 files:
|
||||
查找老派说唱(old-school rap)MP3 文件:
|
||||
|
||||
fselect duration, path from /home/user/music where genre = Rap and bitrate = 320 and mp3_year lt 2000
|
||||
|
||||
Shortcuts to common file extensions:
|
||||
常用文件扩展名的快捷方式:
|
||||
|
||||
fselect path from /home/user where is_archive = true
|
||||
fselect path, mime from /home/user where is_audio = 1
|
||||
fselect path, mime from /home/user where is_book != false
|
||||
|
||||
Even simpler way of using boolean columns:
|
||||
使用布尔列的更简便方式:
|
||||
|
||||
fselect path from /home/user where is_doc
|
||||
fselect path from /home/user where is_image
|
||||
fselect path from /home/user where is_video
|
||||
|
||||
Find files with dangerous permissions:
|
||||
查找具有危险权限的文件:
|
||||
|
||||
fselect mode, path from /home/user where other_write or other_exec
|
||||
fselect mode, path from /home/user where other_all
|
||||
|
||||
Simple glob-like expressions or even regular expressions in file mode are possible:
|
||||
在文件 mode 中可使用简单的类 glob 表达式,甚至正则表达式:
|
||||
|
||||
fselect mode, path from /home/user where mode = '*rwx'
|
||||
fselect mode, path from /home/user where mode =~ '.*rwx$'
|
||||
|
||||
Find files by owner's uid or gid:
|
||||
按所有者的 uid 或 gid 查找文件:
|
||||
|
||||
fselect uid, gid, path from /home/user where uid != 1000 or gid != 1000
|
||||
|
||||
Or by owner's or group's name:
|
||||
或按所有者或组的名称:
|
||||
|
||||
fselect user, group, path from /home/user where user = mike or group = mike
|
||||
|
||||
Find special files:
|
||||
查找特殊文件:
|
||||
|
||||
fselect name from /usr/bin where suid
|
||||
fselect path from /tmp where is_sticky
|
||||
fselect path from /tmp where is_pipe
|
||||
fselect path from /tmp where is_socket
|
||||
|
||||
Find files with xattrs, check if a particular xattr exists, or get its value:
|
||||
查找带有扩展属性(xattrs)的文件,检查特定 xattr 是否存在,或获取其值:
|
||||
|
||||
fselect "path, has_xattrs, has_xattr(user.test), xattr(user.test) from /home/user"
|
||||
|
||||
Include arbitrary text as columns:
|
||||
将任意文本作为列包含:
|
||||
|
||||
fselect "name, ' has size of ', size, ' bytes'"
|
||||
|
||||
Group results:
|
||||
对结果分组:
|
||||
|
||||
fselect "ext, count(*) from /tmp group by ext"
|
||||
fselect "ext, count(*) from /tmp group by 1"
|
||||
fselect "mime, ext, count(*) from /tmp group by 1, 2"
|
||||
|
||||
Order results:
|
||||
对结果排序:
|
||||
|
||||
fselect path from /tmp order by size desc, name
|
||||
fselect modified, fsize, path from ~ order by 1 desc, 3
|
||||
|
||||
Finally, limit the results:
|
||||
最后,限制结果数量:
|
||||
|
||||
fselect name from /home/user/samples limit 5
|
||||
|
||||
Format output:
|
||||
格式化输出:
|
||||
|
||||
fselect size, path from /home/user limit 5 into json
|
||||
fselect size, path from /home/user limit 5 into csv
|
||||
@@ -332,4 +338,4 @@ MIT/Apache-2.0
|
||||
|
||||
---
|
||||
|
||||
Supported by [JetBrains IDEA](https://jb.gg/OpenSourceSupport) open source license
|
||||
由 [JetBrains IDEA](https://jb.gg/OpenSourceSupport) open source license
|
||||
|
||||
Reference in New Issue
Block a user