bfs
Breadth-first file search
TLDR
SYNOPSIS
bfs [options] [path...] [expression]
DESCRIPTION
bfs is a breadth-first variant of the Unix find command. It traverses directories in breadth-first order rather than depth-first, which can be faster for certain operations and more intuitive when printing results.The tool is compatible with GNU find but uses a different traversal strategy.
PARAMETERS
-name pattern
Match filename pattern-type type
File type (f, d, l, etc.)-size n
File size-mtime n
Modification time-exec command ;
Execute command-delete
Delete matched files-depth
Process directory contents before directory-maxdepth n
Maximum depth to descend
BFS-SPECIFIC FLAGS
-j n
Search with N threads in parallel (default: number of CPUs, up to 8)-S bfs|dfs|ids|eds
Select the search strategy: breadth-first (default), depth-first, iterative deepening, or exponential deepening-color / -nocolor
Turn colors on or off (default: -color when output is a terminal)-hidden / -nohidden
Include or exclude hidden files (those beginning with .)-exclude expression
Exclude all paths matching the expression from the search-unique
Skip files that have already been seen (useful with -L)-x
Do not descend into other mount points (same as -xdev)-status
Display a status bar while searching-files0-from file
Read NUL-separated starting paths from a file-D flag
Turn on a debugging flag
DIFFERENCES FROM FIND
- Breadth-first traversal order- Generally faster for -quit operations- More intuitive output ordering- Compatible command-line syntax
WORKFLOW
bfs /home -name "*.pdf"
# Find large files in top levels first
bfs / -size +100M
# Delete empty directories
bfs /tmp -type d -empty -delete
# Find recently modified
bfs /var/log -mtime -1
CAVEATS
Less widely available than find. Different traversal order may affect some operations. Not installed by default on most systems. For complex queries, behavior differences possible.
HISTORY
bfs was created by Tavian Barnes in 2015 as an optimized, breadth-first alternative to the traditional find command.
