Repolode
tavianator

tavianator/bfs

A breadth-first variant of the UNIX find command that lists shallow files before deep ones, compatible with POSIX and BSD/GNU find.

Stars
1,282
Forks
44
Open issues
15
Last commit
9 days ago

What is it?

bfs is a variant of the UNIX find command that walks directory trees breadth-first instead of depth-first. Because it lists files from shallowest to deepest, you do not have to wait for it to exhaust an unrelated deep subtree before reaching the file you are looking for.

It aims to stay compatible with many versions of find, including POSIX, GNU, FreeBSD, OpenBSD, NetBSD and macOS. On top of that it makes common tasks easier: arguments can appear in any order, typos in options get suggestions, and a static analysis pass warns about expressions whose results are ignored. It also adds an -exclude operator that skips whole subtrees, and -nohidden to skip hidden files.

bfs is written in C, is available from many Linux, macOS and BSD package managers, and builds with a configure and make workflow. Optional system libraries such as ACL, attr, libcap, liburing and oniguruma enable additional features.

Key features

  • 01Lists files breadth-first, so shallow matches appear before deep subtrees.
  • 02Accepts options and expressions in flexible positions, unlike strict find.
  • 03Suggests corrections for mistyped arguments.
  • 04Warns about expressions whose results are ignored.
  • 05Provides -exclude to skip whole subtrees and -nohidden to skip hidden files.

Use cases

  • Locating a file in a large project tree when you do not know how deep it sits.
  • Replacing find in scripts while keeping familiar predicates and options.
  • Searching directory trees while skipping .git or other unwanted folders with -exclude.

Quick start

  1. 1

    Install via Homebrew on macOS

    brew install bfs
  2. 2

    Or install from your Linux distribution's package manager (e.g. Arch Linux)

    pacman -S bfs
  3. 3

    Or build from source: download a release or clone the repo, then run configure and make

    ./configure && make

Things to know

  • Building from source requires a C compiler, GNU make, and Bash, plus optional system libraries for full features.

In collections

Topics

FAQ

What is bfs?
A breadth-first variant of the UNIX find command that lists shallow files before deep ones, compatible with POSIX and BSD/GNU find. bfs is a variant of the UNIX find command that walks directory trees breadth-first instead of depth-first. Because it lists files from shallowest to deepest, you do not have to wait for it to exhaust an unrelated deep subtree before reaching the file you are looking for.
Is bfs free to use? What license does it have?
bfs is open source under the 0BSD license. Check the license terms before using it in commercial products.
Is bfs still maintained?
Actively maintained. The last commit to bfs was on Oct 13, 2026.
What can I use bfs for?
Locating a file in a large project tree when you do not know how deep it sits. Replacing find in scripts while keeping familiar predicates and options. Searching directory trees while skipping .git or other unwanted folders with -exclude.
How do I install bfs?
Install via Homebrew on macOS: brew install bfs Or install from your Linux distribution's package manager (e.g. Arch Linux): pacman -S bfs Or build from source: download a release or clone the repo, then run configure and make: ./configure && make
Where can I get bfs?
The source code and installation instructions are on GitHub: https://github.com/tavianator/bfs

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects