#find #command #fuzzy-search #linux #directory #performance #file-path

bin+lib ffind

ffind is a command line utility that performs the core functionality of Linux's find command, with the ability for "fuzzy" searches and significantly better performance

1 unstable release

0.1.0 Mar 29, 2021

#45 in #fuzzy-search

Unlicense OR MIT

160KB
74 lines

ffind

ffind is a limited but more performant version of Linux's find command. In addition to finding the path of the given file name, ffind also supports "fuzzy" searches (hence the additional f). This is useful when trying to find a file without knowing it's exact name.

Future versions of ffind will attempt to implement many of the useful features of Linux's builtin find command.

Usage

ffind [OPTIONS] <query> [starting-dir]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -f, --fuzzy <fuzzy>    

ARGS:
    <query>           
    <starting-dir>

You can generate usage via ffind --help.

Examples

> ffind someFile.txt
/Users/path/to/file/temp/test2Dir/someFile.txt
/Users/path/to/file/temp/test1Dir/someFile.txt

Took 21 msecs.

This command will search for and print the path of any file with name someFile.txt in the current directory.

> ffind someFile.txt test2Dir
test2Dir/someFile.txt

Took 3 msecs.

This command will search for and print the absolute path of any file with name someFile.txt in the myDir directory.

> ffind someFile.txt -f 80
/Users/path/to/file/temp/test2Dir/someFile.txt
/Users/path/to/file/temp/test1Dir/someFile.txt
/Users/path/to/file/temp/test1Dir/someFilee.txtt

Took 6 msecs.

This command will search for and print the absolute path of any file which has a name that is close to someFile.txt in the current directory. The -f flag indicates the use of "fuzzy" search, and the following integer denotes the "strength" of the comparison. Providing a strength of 0 will match anything, while providing a strength of 100 will check for strict string equality. Behind the scenes, ffind uses the Normalized Levenshtein distance implemented by the strsim crate.

Performance

ffind vs. find

As you can see, on my machine, searching for a file name starting at the root directory is approximately 10x faster than Linux's find command.

Dependencies

~3–13MB
~128K SLoC