A find-like tool using Hyperscan for regex matching and threads for fast directory walk.
Inspired by fd.
Implementation:
- fast file tree walk using
fdopendir(3)
,openat(2)
- custom threadpool with simple locking queue
- entries sorted lexically, but output from threads is interleaved (no thread output buffers)
- no
stat(2)
by default, dirs are detected usingO_DIRECTORY
Default ignored files and directories:
- special paths like
/mnt
,/dev
,/proc
are not searched by default - to search in them, either add them explicitly to searched paths or use
-S, --search-in-special-dirs
- for example,
ff tty /
skips/dev
whileff tty / /dev
doesn't skip it - the list of ignored directories is presented in
--help
, under--search-in-special-dirs
option
Single device
- allows skipping any mounted directories that are found during directory walk
- this costs additional
stat(2)
call per directory (usually unnoticeable)
Long listing
ff -l
show file attributesff -L
is a shortcut for output similar tols -lh
- suggested shell alias:
alias lf='ff -L'
Use --stats
in combination with -l
or -t<TYPE>
(both imply stat(2)
calls) to print sum of file sizes.
Example:
-s
is--stats
-tf
filters regular files and also enables size statistics-e 'cpp|h'
filters C++ sources- no matching pattern is used, so we need
--
before the list of paths
Use --xmagic
to filter ELF/Mach-O files. These are executables, libraries, .o files.
Useful inside installation directory (build artifacts) to skip data files and focus on executable code.
Example:
-j1
for ordered output (otherwise, it's interleaved from multiple threads).-l
for detailed listing (file attributes)
Possible features to be added:
- filter files by attributes, e.g. file size (use case: search for large files)
Not planned:
- interpretation of
.gitignore
- This would add a ton of complexity with questionable profit. If you want to hide
build products from search tools like
ff
, then consider building into a hidden directory like.build
.
- This would add a ton of complexity with questionable profit. If you want to hide
build products from search tools like
Build only ff
tool + necessary libs (run from repo root, not tools subdirectory):
./build.sh only-ff