fselect 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
fselect 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
fselect 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 View license
开发语言 Rust
操作系统 跨平台
软件类型 开源软件
所属分类 应用工具文件管理器
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-11-08

软件简介

fselect

Find files with SQL-like queries

Crates.io Build Status

Why use fselect?

While it doesn't tend to fully replace traditional find and ls, fselect has these nice features:

  • SQL-like (not real SQL, but highly relaxed!) grammar easily understandable by humans
  • complex queries
  • aggregate, statistics, date, and other functions
  • search within archives
  • .gitignore, .hgignore, and .dockerignore support (experimental)
  • search by width and height of images, EXIF metadata
  • search by MP3 info
  • search by extended file attributes
  • search by file hashes
  • search by MIME type
  • shortcuts to common file types
  • interactive mode
  • various output formatting (CSV, JSON, and others)

More is under way!

Installation

Latest release from source

  • Install Rust with Cargo and its dependencies to build a binary
  • Run cargo install fselect

Arch Linux

AUR package, thanks to @asm0dey

NixOS

fselect in nixpkgs, thanks to @filalex77

Other Linux

Static build with musl.

Windows 64bit

A statically precompiled binary is available at Github downloads.

Windows from Chocolatey

Mac via Homebrew

  • Install brew
  • Run brew install fselect

Mac via MacPorts

  • Install MacPorts
  • Run:
    sudo port selfupdate
    sudo port install fselect
    

Usage

fselect [ARGS] COLUMN[, COLUMN...] [from ROOT[, ROOT...]] [where EXPR] [order by COLUMNS] [limit N] [into FORMAT]

Interactive mode

fselect -i

Documentation

More detailed description. Look at examples first.

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:

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"

Find files (just names) with any content (size > 0):

fselect name from /home/user/tmp where size gt 0

Specify file size, get absolute path, and add it to the results:

cd /home/user
fselect size, abspath from ./tmp where size gt 2g
fselect fsize, abspath from ./tmp where size = 5m
fselect hsize, abspath from ./tmp where size lt 8k

More complex query:

fselect "name from /tmp where (name = *.tmp and size = 0) or (name = *.cfg and size > 1000000)"

Aggregate functions:

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 an 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 are supported:

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:

fselect name from /home/user where path = '*Rust*'

Classic 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
fselect path from /home/user where accessed = yesterday
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 interval between 3PM and 4PM:

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 possible (find everything updated since May 1st):

fselect path from /home/user where modified gte 2017-05-01

Default is 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):

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:

fselect path, size from /home/user symlinks where name = '*.jpg'

Search within archives (currently only zip-archives are supported):

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:

fselect size, path from /home/user/projects gitignore 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 old-school rap MP3 files:

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
fselect path from /home/user where is_doc != 1
fselect path from /home/user where is_image = false
fselect path from /home/user where is_video != true

Find files with dangerous permissions:

fselect mode, path from /home/user where other_write = true or other_exec = true
fselect mode, path from /home/user where other_all = true

Simple glob-like expressions or even regular expressions on file mode are possible:

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:

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 = true
fselect path from /tmp where is_pipe = true
fselect path from /tmp where is_socket = 1

Find files with xattrs, check if particular xattr exists, or get its value:

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'"

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
fselect size, path from /home/user limit 5 into html

License

MIT/Apache-2.0


Supported by JetBrains IDEA open source license

展开阅读全文

代码

评论 (0)

加载中
更多评论
暂无内容
发表了博客
2016/05/22 17:00

图形化桌面上的脚本编程

1创建文本菜单 创建交互式shell脚本最长用的方法就是使用菜单。提供各种选项帮助脚本用户了解脚本功能。菜单会清空显示区域,然后显示可用的选项列表。 1.1创建菜单函数 菜单布局函数 创建菜单布局函数的第一步是决定菜单上要显示什么,用echo命令显示,在显示前先用clear命令清楚当前终端会话terminfo数据。 函数例子: function menu { clear echo echo -e "\t\t\tSys Admin Menu\n" #-e 选项识别换行符制表符等...

0
6
发表了博客
2018/05/15 21:31

linux dialog详解(图形化shell)

liunx 下的dialog 工具是一个可以和shell脚本配合使用的文本界面下的创建对话框的工具。 每个对话框提供的输出有两种形式: 1. 将所有输出到stderr 输出,不显示到屏幕。 2. 使用退出状态码,“OK”为0,“NO”为1,"ESC"为255 通用选项 common options:(这个选项来设置dialog box的背景,颜色和 标题等) [--title <title>] 指定将在对话框的上方显示的标题字符串 [--colors] 解读嵌入式“\ Z”的对话框中的特殊文本序列,序列由...

0
0
发表了博客
2014/07/03 15:21

IME 接口函数

ImeConversionList:根据输入上下文的有关内容,将一个字符或者字符串转换成远东字符结果列表或者另一个字符串。 此函数的作用是在输入串和结果串之间进行变换以便于进行重新转换,所以在此函数中不应该产生任何相关的输入法编辑器消息; BOOL WINAPI ImeConfigure(HKL hKL,HWND hWnd, DWORD dwMode, LPVOID lpData) 这是最后一个需要注意的接口,在显示输入法属性配置时会Windows会调用这个接口. #ImeConfigure:此接口函数将在用...

0
1
发表了博客
2018/05/15 17:01

[转] 利用shell创建文本菜单与窗口部件的方法

[From] http://www.jb51.net/article/129460.htm 前言 创建交互式shell脚本最常用的方法是使用菜单。提供各种选项可以帮助脚本用户了解脚本能做什么,不能做什么;通常菜单脚本会清空显示区域,然后显示可用的选项列表。本文给大家详细介绍了shell创建文本菜单与窗口部件的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。 创建文本菜单 创建交互式shell脚本最常用的方法是使用菜单,它提供了各种选...

0
0
发表了博客
2014/12/07 14:20

vc编程的ime输入法菜单开发

如何初识 WINDOWS 下 IME 编程 IME 编程心得 第一章 Windows9x 系统下汉字输入法的基本原理 第二章 Windows9x 系统提供的 ime 管理函数 第三章 ime 文件中必须使用的结构 自由拼音输入法的测试 输入法程序 [ime] 的调试方法 输入法 (IME) 实现原理 大家知道, DELPHI 许多控件有 IME 属性。这么好用的东西 VC 可没自带,怎么办呢?其 实,可通过注册表,用 API 实现。下面说一下本人对 IME 的研究结果,并提供示例工程供 大家参...

3
6
发表了博客
2015/04/15 23:40

谈论vc++输入法编程

一直想写一点关于输入法编程的东西,今天终于有点时间,可以练习啦。 我们首先需要明白输入法是什么东西。目前常用的输入法基本上有两种类型:外挂式(如早期的万能五笔)及输入法接口式(Input Method Editor-IME)。外挂式比较简单,就是一个exe文件,通过模拟一些Windows输入消息来给当前处于活动状态的编辑窗口输入文字,一个显著的优点是输入法只要启动一次,就可以在所有进程中使用;但缺点不不容忽视,首先实现起来也不容...

0
2
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部