Find files with SQL-like queries
While it doesn't tend to fully replace traditional find
and ls
, fselect has these nice features:
More is under way!
cargo install fselect
...or download a statically precompiled binary from Github if you are on a modern Windows 64bit
fselect COLUMN[, COLUMN...] from ROOT[, ROOT...] [where EXPR] [limit N]
Find temporary or config files (full path and size):
fselect path, size from /home/user where name = *.cfg or name = *.tmp
Find files (just names) with any content (size > 0):
fselect name from /home/user/tmp where size gt 0
or put arguments into the quotes:
fselect "name from /home/user/tmp where size > 0"
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
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:
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*
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):
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
Shortcuts to common file extensions:
fselect path from /home/user where is_archive = true
fselect path from /home/user where is_audio = 1
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 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
Or by owner's or group's name:
fselect path, user, group from /home/user where user = mike or group = mike
Finally limit the results:
fselect name from /home/user/samples limit 5
path
name
size
uid
gid
user
group
created
accessed
modified
is_dir
is_file
mode
user_read
user_write
user_exec
group_read
group_write
group_exec
other_read
other_write
other_exec
is_archive
is_audio
is_doc
is_image
is_video
=
or eq
!=
or ne
>
or gt
>=
or gte
or ge
<
or lt
<=
or lte
or le
~=
or regexp
or rx
g
or gb
for gibibytesm
or mb
for mibibytesk
or kb
for kibibytes.7zip
, .bzip2
, .gz
, .gzip
, .rar
, .tar
, .xz
, .zip
.aac
, .aiff
, .amr
, .flac
, .gsm
, .m4a
, .m4b
, .m4p
, .mp3
, .ogg
, .wav
, .wma
.accdb
, .doc
, .docx
, .dot
, .dotx
, .mdb
, .ods
, .odt
, .pdf
, .ppt
, .pptx
, .rtf
, .xls
, .xlt
, .xlsx
, .xps
.bmp
, .gif
, .jpeg
, .jpg
, .png
, .tiff
.3gp
, .avi
, .flv
, .m4p
, .m4v
, .mkv
, .mov
, .mp4
, .mpeg
, .mpg
, .webm
, .wmv
MIT/Apache-2.0