Find files (ff) by name, fast!

Overview

Find Files (ff)

Build Status Version info

Find Files (ff) utility recursively searches the files whose names match the specified RegExp pattern in the provided directory (defaults to the current directory if not provided).

Dual-licensed under MIT or the UNLICENSE.

Screenshot

Screenshot

Installation

There are various ways to install ff on your system.

Install using Homebrew

If you use macOS, install ff simply using brew install vishaltelangre/tap/ff.

Download precompiled executables for your platform/OS

Download the latest precompiled executable ff binary for your platform from the releases page.

Install using Cargo

If you're a Rust programmer, download and install ff command using cargo install find-files. To update to a newer version, use the --force flag.

Benchmark Results

$ hyperfine                                \
    --warmup 3                             \
    --export-markdown benchmark-results.md \
    "find . -iregex '.*[0-9]\.jpg$'"       \
    "find . -iname '*[0-9].jpg'"           \
    "fd -HI '.*[0-9]\.jpg$'"               \
    "ff .*[0-9]\.jpg$"

Benchmark #1: find . -iregex '.*[0-9]\.jpg$'
  Time (mean ± σ):      42.8 ms ±   5.5 ms    [User: 11.7 ms, System: 30.1 ms]
  Range (min … max):    31.2 ms …  56.9 ms    48 runs

Benchmark #2: find . -iname '*[0-9].jpg'
  Time (mean ± σ):      60.8 ms ±   7.2 ms    [User: 27.9 ms, System: 31.4 ms]
  Range (min … max):    44.0 ms …  76.2 ms    37 runs

Benchmark #3: fd -HI '.*[0-9]\.jpg$'
  Time (mean ± σ):      18.8 ms ±   5.3 ms    [User: 14.9 ms, System: 19.9 ms]
  Range (min … max):    11.2 ms …  41.6 ms    96 runs

Benchmark #4: ff .*[0-9]\.jpg$
  Time (mean ± σ):      18.7 ms ±   4.6 ms    [User: 15.7 ms, System: 22.5 ms]
  Range (min … max):    11.7 ms …  30.4 ms    123 runs

Summary
  'ff .*[0-9]\.jpg$' ran
    1.00 ± 0.37 times faster than 'fd -HI '.*[0-9]\.jpg$''
    2.29 ± 0.63 times faster than 'find . -iregex '.*[0-9]\.jpg$''
    3.25 ± 0.88 times faster than 'find . -iname '*[0-9].jpg'
Command Mean [ms] Min…Max [ms]
find . -iregex '.*[0-9]\.jpg$' 42.8 ± 5.5 31.2…56.9
find . -iname '*[0-9].jpg' 60.8 ± 7.2 44.0…76.2
fd -HI '.*[0-9]\.jpg$' 18.8 ± 5.3 11.2…41.6
ff .*[0-9]\.jpg$ 18.7 ± 4.6 11.7…30.4

Table: benchmark-results.md

NOTE: Sometimes, fd is a bit faster than ff by approximately 1 ms to 2 ms.

Usage

USAGE:
    ff [FLAGS] [OPTIONS] <PATTERN> [ROOT_PATH]

FLAGS:
    -s, --case-sensitive       Search case sensitively. By default, files are
                               searched case insensitively.
    -D, --exclude-dir-paths    Exclude paths from the search result which are
                               directories and not files.
    -h, --help                 Prints help information
    -G, --ignore-gitignore     Ignore searching files and directories specified
                               in .gitignore. By default, the files and
                               directories specified in .gitignore are included
                               in the search results.
    -H, --ignore-hidden        Ignore searching hidden files and directories. By
                               default, hidden files and directories are
                               included in the search results.
    -V, --version              Prints version information

OPTIONS:
    -x, --exclude <exclude>    Exclude files and directories matching this
                               regular expression from the search results.
    -L, --level <level>        Recursively search only given level directories
                               deep. By default no depth restriction is imposed.
                               A value of 0 would always yield zero results. A
                               value of 1 searches for the direct children in
                               the given path.
    -j, --threads <threads>    The approximate number of threads to use. A value
                               of 0 (which is the default) results in thread
                               count set to available CPU cores.

ARGS:
    <PATTERN>      Find files whose name (path) matches this substring or
                   the regular expression.
    <ROOT_PATH>    Path to the directory to search files inside.[default:
                   `$PWD`]

Examples

There are a tons of possibilities to search files using ff. Following examples demonstrate just a tip of an iceberg.

  • List paths of files recursively in the current working directory matching article string.

    ff article
    
  • List files having .png, or .PNG extension.

    ff png$
    
  • List files having strict .PNG extension.

    ff -s PNG$
    
  • Search various image files.

    ff "\.(png|jpg|jpeg|gif|svg)$"
    
  • List files whose path matches controllers string.

    ff controllers
    
  • Search .js files in ./spec directory.

    ff \.js ./spec
    
  • Search a file which is expected to be inside hidden .git directory whose name contains commit or something similar.

    $ ff git.*commit
    
    ./.git/COMMIT_EDITMSG
    # omitted other results
  • Do not show hidden files and directories in the search results.

    ff something -H
    
  • Do not show those files and directories in the search results which are enlisted in .gitignore.

    ff src/.*js$ -G
    

    Without -G (--ignore-gitignore) flag in the above command, it also includes the results in the directories such as node_modules by default.

  • Do not show paths which are just directories and not actual files.

    $ ff -D user
    
    ./app/models/user.rb
    ./app/models/user/address.rb
    ./specs/models/user_spec.rb
    ./specs/models/user/address_spec.rb

    Without -D (--exclude-dir-paths) flag in the above command, it also includes the paths of the matching directories in the results as follows.

    $ ff user
    
    ./app/models/user.rb
    ./app/models/user
    ./app/models/user/address.rb
    ./specs/models/user_spec.rb
    ./specs/models/user
    ./specs/models/user/address_spec.rb
  • Exclude (omit) files and directories which match the provided optional exclude RegExp pattern.

    ff rb$ app/controllers -x /(audit|admin|sso|api)/
    

    Above command will show paths of all files whose name ends with rb inside the relative app/controllers directory excluding the paths which match /(audit|admin|sso|api)/ pattern.

  • Limit searching beyond 3 levels deep in the given path.

    ff -L 3 .js$
    
Comments
  • [Feature] Parametrize the ability to include only files.

    [Feature] Parametrize the ability to include only files.

    Be able to exclude directories without using a regular expression.

    Description

    There is an ambiguity between a file or folder. A file can have no extension, so there is no way using a regular expression to distinguish between a file or a folder.

    e.g. /home/user/ambigous_name

    is it a file, or a folder? because ff will output this and there is no regular expression that can guarantee this to get filtered.

    I did a simple test that gets the following output.

    dev@rasp03:/home/dev/test $ ff .
    .
    ./this_is_a_file
    ./this_is_a_folder
    

    Motivation

    The reason for this is that I want to replace the default vim command for https://github.com/ctrlpvim/ctrlp.vim extension (for obvious reasons).

    I am using the following, actually.

    let g:ctrlp_user_command = 'ff . %s -x "/$"'

    But unluckily it also includes directories. As an example, the default command will be the following.

    let g:ctrlp_user_command = 'find %s -type f'

    It could be a good start point as choicing the way/parameter name for this.

    Final

    If you find this is already implemented or not relevant, please let me know so I can look for a workaround, and also thanks for this great tool!

    enhancement 
    opened by Shaddy 3
  • Replace `\` with `/` in path printer

    Replace `\` with `/` in path printer

    When someone pipes output from this program, the backslashes are recognized as a special character.

    For example, if I want to remove all exe files from the current directory, I would need to do something like that:

    ff \.exe$ | sed s/\\/\//g | xargs rm
    

    With this change I can do this:

    ff \.exe$ | xargs rm
    
    opened by Milesq 1
  • Please do not pollute the two lettered namespace

    Please do not pollute the two lettered namespace

    Using a short name like ff makes me very hesitant to install this tool. Such convenient names should be reserved for user aliases, not for any program to claim. I suggest you change the binary's name to ffind, and add a simple alias ff=ffind to the installation guide.

    opened by NightMachinery 1
  • Enable LTO and improve search speed

    Enable LTO and improve search speed

    • LTO helps to speedup compile time and reduce binary size (Reference: https://github.com/johnthagen/min-sized-rust#enable-link-time-optimization-lto).
    • Also, added benchmark results.
    opened by vishaltelangre 0
  • The tool should include hidden subdirectories by default

    The tool should include hidden subdirectories by default

    Test env:

    • at my home dir, searched for ff ssh

    • ./.ssh/id_rsa.pub was not found, for example

    • with find . | grep ssh

    • it was.

    IMHO to include hidden dirs should be the default behavior (since I'm looking for it... and don't know where it is).

    Maybe an argument --ingore-hidden-dirscould also be a nice thing (in which would present the current behavior)

    In any case, it's a great tool and congratulations!

    Cheers

    opened by mariobaldini 0
Releases(v0.1.8)
Owner
Vishal Telangre
Creator of @wassuphq. Author of "Networking Microservices using Consul" book.
Vishal Telangre
Find all your TODO notes with one command!

Todo_r Find all your notes with one command! Todo_r is a simple rust command line utility that keeps track of your todo items in code. It is pronounce

Lavi Blumberg 34 Apr 22, 2022
⏮ ⏯ ⏭ A Rust library to easily read forwards, backwards or randomly through the lines of huge files.

EasyReader The main goal of this library is to allow long navigations through the lines of large files, freely moving forwards and backwards or gettin

Michele Federici 81 Dec 6, 2022
Splits test files into multiple groups to run tests in parallel nodes

split-test split-test splits tests into multiple groups based on timing data to run tests in parallel. Installation Download binary from GitHub releas

Fumiaki MATSUSHIMA 28 Dec 12, 2022
Difftastic is an experimental structured diff tool that compares files based on their syntax.

Difftastic is an experimental structured diff tool that compares files based on their syntax.

Wilfred Hughes 13.9k Jan 2, 2023
Subtitles-rs - Use SRT subtitle files to study foreign languages

Rust subtitle utilities Are you looking for substudy? Try here. (substudy has been merged into the subtitles-rs project.) This repository contains a n

Eric Kidd 268 Dec 29, 2022
A command line tool for renaming your ipa files quickly and easily.

ipa_renamer A command line tool for renaming your ipa files quickly and easily. Usage ipa_renamer 0.0.1 A command line tool for renaming your ipa file

Noah Hsu 31 Dec 31, 2022
Fast suffix arrays for Rust (with Unicode support).

suffix Fast linear time & space suffix arrays for Rust. Supports Unicode! Dual-licensed under MIT or the UNLICENSE. Documentation https://docs.rs/suff

Andrew Gallant 207 Dec 26, 2022
Rust edit distance routines accelerated using SIMD. Supports fast Hamming, Levenshtein, restricted Damerau-Levenshtein, etc. distance calculations and string search.

triple_accel Rust edit distance routines accelerated using SIMD. Supports fast Hamming, Levenshtein, restricted Damerau-Levenshtein, etc. distance cal

Daniel Liu 75 Jan 8, 2023
💥 Fast State-of-the-Art Tokenizers optimized for Research and Production

Provides an implementation of today's most used tokenizers, with a focus on performance and versatility. Main features: Train new vocabularies and tok

Hugging Face 6.2k Jan 5, 2023
A fast, low-resource Natural Language Processing and Text Correction library written in Rust.

nlprule A fast, low-resource Natural Language Processing and Error Correction library written in Rust. nlprule implements a rule- and lookup-based app

Benjamin Minixhofer 496 Jan 8, 2023
A fast implementation of Aho-Corasick in Rust.

aho-corasick A library for finding occurrences of many patterns at once with SIMD acceleration in some cases. This library provides multiple pattern s

Andrew Gallant 662 Dec 31, 2022
Fast and easy random number generation.

alea A zero-dependency crate for fast number generation, with a focus on ease of use (no more passing &mut rng everywhere!). The implementation is bas

Jeff Shen 26 Dec 13, 2022
Vaporetto: a fast and lightweight pointwise prediction based tokenizer

?? VAporetto: POintwise pREdicTion based TOkenizer Vaporetto is a fast and lightweight pointwise prediction based tokenizer. Overview This repository

null 184 Dec 22, 2022
Blazingly fast framework for in-process microservices on top of Tower ecosystem

norpc = not remote procedure call Motivation Developing an async application is often a very difficult task but building an async application as a set

Akira Hayakawa 15 Dec 12, 2022
Composable n-gram combinators that are ergonomic and bare-metal fast

CREATURE FEATUR(ization) A crate for polymorphic ML & NLP featurization that leverages zero-cost abstraction. It provides composable n-gram combinator

null 3 Aug 25, 2022
A simple and fast linear algebra library for games and graphics

glam A simple and fast 3D math library for games and graphics. Development status glam is in beta stage. Base functionality has been implemented and t

Cameron Hart 953 Jan 3, 2023
Ultra-fast, spookily accurate text summarizer that works on any language

pithy 0.1.0 - an absurdly fast, strangely accurate, summariser Quick example: pithy -f your_file_here.txt --sentences 4 --help: Print this help messa

Catherine Koshka 13 Oct 31, 2022
Fast PDF password cracking utility equipped with commonly encountered password format builders and dictionary attacks.

PDFRip Fast PDF password cracking utility equipped with commonly encountered password format builders and dictionary attacks. ?? Table of Contents Int

Mufeed VH 226 Jan 4, 2023
🛥 Vaporetto is a fast and lightweight pointwise prediction based tokenizer. This is a Python wrapper for Vaporetto.

?? python-vaporetto ?? Vaporetto is a fast and lightweight pointwise prediction based tokenizer. This is a Python wrapper for Vaporetto. Installation

null 17 Dec 22, 2022