Simplified Find command made with Rust.

Overview

Hunt

Hunt is a (highly-opinionated) simplified Find command made with Rust.
It searches a file/folder by name on the entire drive.

If the --first flag is set, the order on which the file will be searched is [current_dir, home_dir, root].
If you're already in one of these directories, "current_dir" will be skipped.

Usage

hunt [OPTIONS] <NAME> <LIMIT_TO_DIRS>...

Options

-e, --exact    Only search for exactly matching occurrences
-f, --first    Stop when first occurrence is found
-h, --help     Print help information

    --starts <STARTS_WITH> 
               Only files that start with this will be found

    --ends   <ENDS_WITH>
               Only files that end with this will be found

-t, --type   <FILE_TYPE>
               Specifies the type of the file
               'f' -> file
               'd' -> directory

-v, --verbose  Print verbose output
               It'll show all errors found: e.g. "Could not read /proc/81261/map_files"

-s, --simple   Prints without formatting (without "Contains:" and "Exact:")
               Useful for pairing it with other commands like xargs

Args

<NAME>  Name of the file/folder to search

<LIMIT_TO_DIRS>...
        Directories where you want to search
        If provided, hunt will only search there
        
        These directories are treated independently, so if one is nested into another the
        search will be done two times:  
        
        e.g. "hunt somefile /home/user /home/user/downloads" will search in the home
        directory, and because /home/user/downloads is inside it, /downloads will be
        traversed two times

Examples

Search for a specific file on the whole system (hunt will stop once found)

hunt -f -e SomeFile

Search for files containing "SomeFile"

hunt SomeFile

Search file in the home directory

hunt -e SomeFile ~/

Search file in the downloads and pictures directories

hunt -e SomeFile ~/downloads ~/pictures

Search all files that end with ".exe"

hunt --ends .exe

Search all files that end with ".exe" in the wine directory

hunt --ends .exe ~/.wine

Search all files that start with "." (all hidden files)

hunt --starts .

Search all files that end with ".exe", start with "M" and contain "wind" in the wine directory

hunt --starts=M --ends=.exe wind ~/.wine

Search a directory named "folder"

hunt -t=d folder

Search a file named "notfolder"

hunt -t=f notfolder

Remove all files named "SomeFile"

hunt -s -e SomeFile | xargs rm -r

Why I made it?

I found I used the find command just to search one file, so I wanted a simpler and faster option.

Hunt is multithreaded, so it's a lot faster than find, and more reliable than locate (recent files cannot be found with it).

Installation

First check that you have Rust installed, then run

cargo install hunt

Benchmarks

This benchmarks are done in a system with approximately 2,762,223 files, with a Network Drive and an external one.
Results on other systems may vary, so take this comparisons as a guide.
(All benchmarks have been done multiple times and the average has been taken)

Searching file in ~/

Find only first occurrence of a heavily nested file from the home directory.

Hunt

~ ❯ time hunt -f -e SomeFile ~/
/home/lyon/.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile

 
________________________________________________________
Executed in   33,38 millis    fish           external
   usr time  107,91 millis    1,17 millis  106,74 millis
   sys time   36,07 millis    0,00 millis   36,07 millis

Find

~ ❯ time find ~/ -name SomeFile -print -quit
./.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile

________________________________________________________
Executed in    1,09 secs      fish           external
   usr time  245,30 millis    1,24 millis  244,06 millis
   sys time  378,23 millis    0,00 millis  378,23 millis

Locate

~ ❯ time locate -n 1 -A SomeFile
/home/lyon/.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile

________________________________________________________
Executed in  253,09 millis    fish           external
   usr time  322,54 millis    1,23 millis  321,31 millis
   sys time   10,23 millis    0,00 millis   10,23 millis

Fd

~ ❯ time fd -H --max-results 1 -c never SomeFile .
./.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile

________________________________________________________
Executed in  177,23 millis    fish           external
   usr time  961,45 millis    1,20 millis  960,25 millis
   sys time  931,60 millis    0,00 millis  931,60 millis

Searching all files that contain SomeFile

Find all occurrences of "SomeFile" from the root directory.

Hunt

/ ❯ time hunt SomeFile
Contains:
/home/lyon/Downloads/abcdefgSomeFileeee
/SomeFileIsHere
/mnt/Files/--SomeFile--

Exact:
/home/lyon/.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile


________________________________________________________
Executed in  560,58 millis    fish           external
   usr time    1,95 secs    501,00 micros    1,95 secs
   sys time    2,67 secs    276,00 micros    2,67 secs

Find

/ ❯ time sudo find -name "*SomeFile*"
./mnt/Files/--SomeFile--
./home/lyon/Downloads/abcdefgSomeFileeee
./home/lyon/.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile
./SomeFileIsHere

________________________________________________________
Executed in    2,48 secs    fish           external
   usr time    1,22 secs    0,00 millis    1,22 secs
   sys time    1,31 secs    1,50 millis    1,31 secs

Locate

/ ❯ time locate SomeFile
/SomeFileIsHere
/home/lyon/.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile
/home/lyon/Downloads/abcdefgSomeFileeee

________________________________________________________
Executed in  488,23 millis    fish           external
   usr time  550,95 millis  432,00 micros  550,52 millis
   sys time   13,70 millis  238,00 micros   13,47 millis

Locate is obviously faster, as it doesn't traverse all the files (it is supported by a db), but as you can see files on other drives are not detected, meaning "/mnt/Files/--SomeFile--" is not in the list.

Fd

/ ❯ time fd -H -c never SomeFile
SomeFileIsHere
home/lyon/.wine/drive_c/Program Files (x86)/Internet Explorer/SomeFile
home/lyon/Downloads/abcdefgSomeFileeee
mnt/Files/--SomeFile--

________________________________________________________
Executed in    1,59 secs    fish           external
   usr time    5,28 secs  478,00 micros    5,28 secs
   sys time    9,01 secs  264,00 micros    9,01 secs

Conclusion

Hunt is faster than other alternatives if you don't need a lot of features (like regex).
Think of it as a simple "where did I put that file?" solution.

You might also like...
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

Message authentication code algorithms written in pure Rust

RustCrypto: Message Authentication Codes Collection of Message Authentication Code (MAC) algorithms written in pure Rust. Supported Algorithms Algorit

Experimenting with Rust implementations of IP address lookup algorithms.

This repository contains some very rough experimentation with Rust implementations of IP address lookup algorithms, both my own and comparison with th

An example of web application by using Rust and Axum with Clean Architecture.

stock-metrics Stock price and stats viewer. Getting Started Middleware Launch the middleware by executing docker compose: cd local-middleware docker c

2 and 3-dimensional collision detection library in Rust.

2D Documentation | 3D Documentation | User Guide | Forum ⚠️ **This crate is now passively-maintained. It is being superseded by the Parry project.** ⚠

Shogun search - Learning the principle of search engine. This is the first time I've written Rust.

shogun_search Learning the principle of search engine. This is the first time I've written Rust. A search engine written in Rust. Current Features: Bu

Image search example by approximate nearest-neighbor library In Rust

rust-ann-search-example Image search example by approximate nearest-neighbor library In Rust use - tensorflow 0.17.0 - pretrain ResNet50 - hora (Ru

Tantivy is a full text search engine library written in Rust.
Tantivy is a full text search engine library written in Rust.

Tantivy is a full text search engine library written in Rust. It is closer to Apache Lucene than to Elasticsearch or Apache Solr in the sense it is no

Tantivy is a full-text search engine library inspired by Apache Lucene and written in Rust
Tantivy is a full-text search engine library inspired by Apache Lucene and written in Rust

Tantivy is a full-text search engine library written in Rust. It is closer to Apache Lucene than to Elasticsearch or Apache Solr in the sense it is no

Comments
  • Bump crossbeam-utils from 0.8.6 to 0.8.8

    Bump crossbeam-utils from 0.8.6 to 0.8.8

    Bumps crossbeam-utils from 0.8.6 to 0.8.8.

    Release notes

    Sourced from crossbeam-utils's releases.

    crossbeam-utils 0.8.8

    • Fix a bug when unstable loom support is enabled. (#787)

    crossbeam-utils 0.8.7

    • Add AtomicCell<{i*,u*}>::{fetch_max,fetch_min}. (#785)
    • Add AtomicCell<{i*,u*,bool}>::fetch_nand. (#785)
    • Fix unsoundness of AtomicCell<{i,u}64> arithmetics on 32-bit targets that support Atomic{I,U}64 (#781)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Post results incrementally

    Post results incrementally

    When using -ss, the results are still delivered as one batch after a few seconds if searching my whole system. For piping to a fuzzy finder, it would be handy if the results were posted incrementally with that option.

    opened by xeruf 0
  • auto-detect path type specified in cli command invocation and use the same for the output results

    auto-detect path type specified in cli command invocation and use the same for the output results

    Firstly, I wanted to say the performance of hunt is outstanding. What took me 2 minutes 8 seconds in find, took 10 seconds in hunt. You should be getting more stars.

    The issue I have is with the simple output displaying the full path of the filename when a full path was not described in the cli command. In other words, please have hunt auto-detect explicit path or relative path usage in the cli command and adjust the results output accordingly to use the same path type(relative path or full explicit path).

    find using a relative path(the dot .). Please notice the result also uses a relative path since it auto-detected it:

    time find . -type f -name "SCP_173 -print > ../allFindResults.txt
    ./rooms/room-999/SCP_173
    

    hunt using a relative path(the dot .). Please notice the result contained full explicit path, but that was undesired since the cli command never used a full explicit path. Also note it creates much bigger results since each line in the result has a longer full path.

    time hunt -c -h -t f -s -e SCP_173 . > ../allHuntExactResults.txt
    /mnt/someremotedrive/a/b/c/d/thispathcouldbeverylong/andtheresultfilewillbemuchlarger/rooms/room-999/SCP_173
    

    The change request is to achieve a similar looking result file and exact same file size as find, but using hunt.

    time hunt -c -h -t f -s -e SCP_173 . > ../allHuntExactResults.txt
    ./rooms/room-999/SCP_173
    

    Thank you for listening.

    opened by omac777 3
Owner
LyonSyonII
LyonSyonII
🔎 Impossibly fast web search, made for static sites.

Stork Impossibly fast web search, made for static sites. Stork is two things. First, it's an indexer: it indexes your loosely-structured content and c

James Little 2.5k Dec 27, 2022
Tantivy is a full-text search engine library inspired by Apache Lucene and written in Rust

Tantivy is a full text search engine library written in Rust. It is closer to Apache Lucene than to Elasticsearch or Apache Solr in the sense it is no

tantivy 7.4k Dec 28, 2022
A full-text search and indexing server written in Rust.

Bayard Bayard is a full-text search and indexing server written in Rust built on top of Tantivy that implements Raft Consensus Algorithm and gRPC. Ach

Bayard Search 1.8k Dec 26, 2022
AI-powered search engine for Rust

txtai: AI-powered search engine for Rust txtai executes machine-learning workflows to transform data and build AI-powered text indices to perform simi

NeuML 69 Jan 2, 2023
A full-text search engine in rust

Toshi A Full-Text Search Engine in Rust Please note that this is far from production ready, also Toshi is still under active development, I'm just slo

Toshi Search 3.8k Jan 7, 2023
Official Elasticsearch Rust Client

elasticsearch   Official Rust Client for Elasticsearch. Full documentation is available at https://docs.rs/elasticsearch The project is still very muc

elastic 574 Jan 5, 2023
🐎 Daac Horse: Double-Array Aho-Corasick in Rust

?? daachorse Daac Horse: Double-Array Aho-Corasick Overview A fast implementation of the Aho-Corasick algorithm using Double-Array Trie. Examples use

null 140 Dec 16, 2022
Strongly typed Elasticsearch DSL written in Rust

Strongly typed Elasticsearch DSL written in Rust This is an unofficial library and doesn't yet support all the DSL, it's still work in progress. Featu

null 173 Jan 6, 2023
Searching for plain-text files for lines that match a given string. Built with Rust.

Getting Started This is a minimal grep command-line utility built on Rust. It provides searching for plain-text files for lines that match a given str

Harsh Karande 0 Dec 31, 2021
A Rust API search engine

Roogle Roogle is a Rust API search engine, which allows you to search functions by names and type signatures. Progress Available Queries Function quer

Roogle 342 Dec 26, 2022