All Projects → tavianator → Bfs

tavianator / Bfs

Licence: 0bsd
A breadth-first version of the UNIX find command

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Bfs

findlargedir
find all "blackhole" directories with a huge amount of filesystem entries in a flat structure
Stars: ✭ 15 (-95.54%)
Mutual labels:  unix, filesystem, find
BSDCoreUtils
BSD coreutils is a port of many utilities from BSD to Linux and macOS.
Stars: ✭ 30 (-91.07%)
Mutual labels:  unix, bsd
Fd
A simple, fast and user-friendly alternative to 'find'
Stars: ✭ 19,851 (+5808.04%)
Mutual labels:  command-line, filesystem
ModernOperatingSystems AndrewTanenbaum
My notes after reading 'Modern Operating Systems' book by Andrew Tanenbaum and Herbert Bos.
Stars: ✭ 71 (-78.87%)
Mutual labels:  unix, filesystem
bf256
Brainfuck compiler under 256 bytes in size.
Stars: ✭ 21 (-93.75%)
Mutual labels:  unix, bsd
InitWare
The InitWare Suite of Middleware allows you to manage services and system resources as logical entities called units. Its main component is a service management ("init") system.
Stars: ✭ 164 (-51.19%)
Mutual labels:  unix, bsd
FreeBSD-Ask
FreeBSD 教程——FreeBSD 从入门到跑路。
Stars: ✭ 113 (-66.37%)
Mutual labels:  unix, bsd
Snapstub
Copy API endpoints to your fs and run a local server using them
Stars: ✭ 193 (-42.56%)
Mutual labels:  command-line, unix
whichpm
Locates installed Perl modules.
Stars: ✭ 20 (-94.05%)
Mutual labels:  unix, filesystem
mrouted
The original DVMRP (dynamic multicast routing) implementation for UNIX
Stars: ✭ 58 (-82.74%)
Mutual labels:  unix, bsd
go-sysconf
sysconf for Go, without using cgo
Stars: ✭ 119 (-64.58%)
Mutual labels:  unix, bsd
Ff
Find files (ff) by name, fast!
Stars: ✭ 257 (-23.51%)
Mutual labels:  command-line, find
Advanced-xv6
Modern improvements for MIT's xv6 OS
Stars: ✭ 26 (-92.26%)
Mutual labels:  unix, filesystem
InitKit
Neo-InitWare is a modular, cross-platform reimplementation of the systemd init system. It is experimental.
Stars: ✭ 364 (+8.33%)
Mutual labels:  unix, bsd
Survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
Stars: ✭ 2,843 (+746.13%)
Mutual labels:  command-line, unix
mg
OpenBSD Mg editor. Portable Public Domain Micro Emacs for *BSD, Cygwin, Linux, Mac OS X.
Stars: ✭ 99 (-70.54%)
Mutual labels:  unix, bsd
Simple
The Simple Intelligent and Modular Programming Language and Environment
Stars: ✭ 120 (-64.29%)
Mutual labels:  command-line, unix
Nnn
n³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+3810.12%)
Mutual labels:  command-line, filesystem
ccalendar
Chinese Calendar in calendar(1) for BSD, Linux & macOS
Stars: ✭ 17 (-94.94%)
Mutual labels:  unix, bsd
4bsd-uucp
Simulate a UUCP network with 4.3BSD SimH images
Stars: ✭ 28 (-91.67%)
Mutual labels:  unix, bsd

bfs

License Version Travis CI Status

Breadth-first search for your files.

Screenshot

bfs is a variant of the UNIX find command that operates breadth-first rather than depth-first. It is otherwise compatible with many versions of find, including

If you're not familiar with find, the GNU find manual provides a good introduction.

Breadth vs. depth

The advantage of breadth-first over depth first search is that it usually finds the file(s) you're looking for faster. Imagine the following directory tree:

haystack
├── deep
│   └── 1
│       └── 2
│           └── 3
│               └── 4
│                   └── ...
└── shallow
    └── needle

find will explore the entire deep directory tree before it ever gets to the shallow one that contains what you're looking for.

$ find haystack
haystack
haystack/deep
haystack/deep/1
haystack/deep/1/2
haystack/deep/1/2/3
haystack/deep/1/2/3/4
...
haystack/shallow
haystack/shallow/needle

On the other hand, bfs lists files from shallowest to deepest, so you never have to wait for it to explore an entire unrelated subtree.

$ bfs haystack
haystack
haystack/deep
haystack/shallow
haystack/deep/1
haystack/shallow/needle
haystack/deep/1/2
haystack/deep/1/2/3
haystack/deep/1/2/3/4
...

Easy

bfs tries to be easier to use than find, while remaining compatible. For example, bfs is less picky about where you put its arguments:

$ find -L -name 'needle' haystack
find: paths must precede expression: haystack
$ bfs -L -name 'needle' haystack
haystack/needle

$ find haystack -L -name 'needle'
find: unknown predicate `-L'
$ bfs haystack -L -name 'needle'
haystack/needle

$ find -L haystack -name 'needle'
haystack/needle
$ bfs -L haystack -name 'needle'
haystack/needle

bfs also adds some extra options that make some common tasks easier. Compare

bfs -name config -exclude -name .git

vs.

find ! \( -name .git -prune \) -name config

Try it!

Packaging status

bfs may already be packaged for your distribution of choice. For example:

Alpine Linux
# apk add bfs

Debian/Ubuntu
# apt install bfs

NixOS
# nix-env -i bfs

Void Linux
# xbps-install -S bfs

FreeBSD
# pkg install bfs

MacPorts
# port install bfs

Homebrew
$ brew install tavianator/tap/bfs

To install bfs from source, download one of the releases or clone the git repo. Then run

$ make

This will build the bfs binary in the current directory. You can test it out:

$ ./bfs -nohidden

If you're interested in speed, you may want to build the release version instead:

$ make release

Finally, if you want to install it globally, run

$ sudo make install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].