fselect/README.md

163 lines
4.3 KiB
Markdown
Raw Normal View History

2018-01-26 15:36:46 +03:00
# fselect
Find files with SQL-like queries
2018-02-02 00:17:52 +03:00
### Why use fselect?
While it doesn't tend to fully replace traditional `find` and `ls`, **fselect** has these nice features:
* complex queries
* SQL-like (not real SQL, but highly relaxed!) grammar easily understandable by humans
* shortcuts to common file types
More is under way!
2018-01-29 12:23:59 +03:00
### Installation
2018-01-29 12:24:22 +03:00
* Install [Rust with Cargo](https://www.rust-lang.org/en-US/install.html) and its dependencies to build a binary
2018-01-29 12:23:59 +03:00
* Run `cargo install fselect`
2018-01-29 12:24:59 +03:00
...or download a statically precompiled binary from Github if you are on a modern Windows 64bit
2018-01-29 12:23:59 +03:00
2018-01-26 15:36:46 +03:00
### Examples
2018-02-03 21:23:52 +03:00
Find temporary or config files (full path and size):
2018-01-26 15:36:46 +03:00
2018-02-02 10:53:46 +03:00
fselect path, size from /home/user where name = *.cfg or name = *.tmp
2018-01-26 15:36:46 +03:00
2018-01-27 13:31:22 +03:00
Find files (just names) with any content (size > 0):
2018-01-26 15:36:46 +03:00
fselect name from /home/user/tmp where size gt 0
2018-01-27 13:31:22 +03:00
or put arguments into the quotes:
2018-01-26 15:36:46 +03:00
fselect "name from /home/user/tmp where size > 0"
2018-01-30 22:31:38 +03:00
Specify file size:
fselect path from /home/user where size gt 2g
fselect path from /home/user where size = 5m
fselect path from /home/user where size lt 8k
2018-01-26 15:36:46 +03:00
More complex query:
fselect name from /tmp where (name = *.tmp and size = 0) or (name = *.cfg and size gt 1000000)
Use single quotes if you need to address files with spaces:
2018-01-27 13:31:22 +03:00
fselect path from '/home/user/Misc stuff' where name != 'Some file'
Regular expressions supported:
fselect name from /home/user where path ~= .*Rust.*
And even simple glob will suffice:
fselect name from /home/user where path = *Rust*
2018-01-29 01:14:26 +03:00
Find files by creation date:
fselect path from /home/user where created = 2017-05-01
Be more specific to match all files created at 3PM:
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):
2018-01-30 10:10:06 +03:00
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 maximum depth specified:
fselect path from /home/user/oldstuff depth 5 where name = *.jpg
fselect path from /home/user/oldstuff depth 5, /home/user/newstuff depth 10 where name = *.jpg
2018-02-02 10:53:46 +03:00
Shortcuts to common file extensions:
fselect path from /home/user where is_archive = true
fselect path from /home/user where is_audio = 1
2018-02-05 18:47:15 +03:00
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
2018-02-05 18:29:24 +03:00
Find files with dangerous permissions:
fselect path, mode from /home/user where other_write = true or other_exec = true
Simple glob-like expressions or even regular expressions on file mode are possible:
fselect path, mode from /home/user where mode = *rwx
fselect path, mode from /home/user where mode ~= .*rwx$
Find files by owner's uid or gid:
fselect path, uid, gid from /home/user where uid != 1000 or gid != 1000
2018-01-27 13:31:22 +03:00
### Columns and expression fields
* `path`
* `name`
* `size`
* `uid`
* `gid`
2018-01-29 01:14:26 +03:00
* `created`
* `accessed`
* `modified`
2018-02-01 23:59:35 +03:00
* `is_dir`
* `is_file`
2018-02-05 18:29:24 +03:00
* `mode`
* `user_read`
* `user_write`
* `user_exec`
* `group_read`
* `group_write`
* `group_exec`
* `other_read`
* `other_write`
* `other_exec`
2018-02-02 10:53:46 +03:00
* `is_archive`
* `is_audio`
2018-02-05 18:47:15 +03:00
* `is_doc`
2018-02-02 10:53:46 +03:00
* `is_image`
* `is_video`
2018-01-27 13:31:22 +03:00
### Operators
* `=` or `eq`
* `!=` or `ne`
* `>` or `gt`
* `>=` or `gte`
* `<` or `lt`
* `<=` or `lte`
* `~=` or `regexp` or `rx`
2018-01-29 12:23:59 +03:00
2018-01-30 22:31:38 +03:00
### File size specifiers
* `g` or `gb` for gibibytes
* `m` or `mb` for mibibytes
* `k` or `kb` for kibibytes
### File extensions
2018-02-05 18:30:41 +03:00
* is_archive: `.7zip`, `.bzip2`, `.gz`, `.gzip`, `.rar`, `.tar`, `.xz`, `.zip`
* is_audio: `.aac`, `.aiff`, `.amr`, `.flac`, `.gsm`, `.m4a`, `.m4b`, `.m4p`, `.mp3`, `.ogg`, `.wav`, `.wma`
2018-02-05 18:42:30 +03:00
* is_doc: `.accdb`, `.doc`, `.docx`, `.dot`, `.dotx`, `.mdb`, `.ods`, `.odt`, `.pdf`, `.ppt`, `.pptx`, `.rtf`, `.xls`, `.xlt`, `.xlsx`, `.xps`
* is_image: `.bmp`, `.gif`, `.jpeg`, `.jpg`, `.png`, `.tiff`
* is_video: `.3gp`, `.avi`, `.flv`, `.m4p`, `.m4v`, `.mkv`, `.mov`, `.mp4`, `.mpeg`, `.mpg`, `.webm`, `.wmv`
2018-01-29 12:23:59 +03:00
### License
MIT/Apache-2.0