bfs
Version 4.0.4
bfs功能•安装•用法•建筑物•贡献•ChangElog
bfs是Unix find命令的变体,该命令是首先操作广度优先而不是深度优先。否则它与许多find兼容,包括
POSIX•GNU•FREEBSD•OPENBSD•NETBSD•MACOS
如果您不熟悉find ,GNU查找手册会提供很好的介绍。
bfs操作广度优先,通常会找到您要寻找的文件。想象以下目录树:
草垛
├ - 深
││└─-1
2
3
││└─4
││└─......................................
└ - 浅
└ -针
find将探索整个deep目录树,然后才能到达包含所需的shallow 。另一方面, bfs列出了从浅到最深的文件,因此您不必等待它来探索整个无关的子树。
bfs | find |
|---|---|
$ bfs haystack
haystack
haystack/deep
haystack/shallow
haystack/deep/1
haystack/shallow/needle
... | $ 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 |
bfs试图比find更容易使用,同时保持兼容。例如, bfs对您提出的论点的挑剔不太挑剔:
bfs | find |
|---|---|
$ bfs -L -name ' needle ' haystack
haystack/needle
$ bfs haystack -L -name ' needle '
haystack/needle
$ bfs -L haystack -name ' needle '
haystack/needle | $ find -L -name ' needle ' haystack
find: paths must precede expression: haystack
$ find haystack -L -name ' needle '
find: unknown predicate `-L'
$ find -L haystack -name ' needle '
haystack/needle |
bfs会出现有用的错误和警告。例如, bfs将检测并建议对错别字进行更正:
$ bfs -nam needle
bfs: error: bfs -nam needle
bfs: error: ~~~~
bfs: error: Unknown argument; did you mean -name? bfs还包括一个强大的静态分析,以帮助捕获错误:
$ bfs -print -name ' needle '
bfs: warning: bfs -print -name needle
bfs: warning: ~~~~~~~~~~~~
bfs: warning: The result of this expression is ignored.bfs添加了一些使常见任务更容易的选项。例如,每当表达式匹配时, -exclude操作员都会跳过整个子树。 - 与标准的-prune仪动作相比, -exclude更强大,更易于使用;比较
$ bfs -name config -exclude -name .git
等效
$找到! (-name .git -prune ) -Name配置
作为额外的速记, -nohidden跳过所有隐藏的文件和目录。有关bfs提供的扩展,请参见使用文档。
bfs可能已经为您的操作系统打包。| Linux | macos |
|---|---|
高山Linux #APK添加BFS Arch Linux #Pacman -s BFS Debian/Ubuntu #APT安装BFS Fedora Linux #DNF安装BFS Gentoo #出现sys-apps/bfs gnu guix #GUIX安装BFS 尼克斯 #NIX -ENV -I BFS void linux #xbps -install -s bfs | 自制 $ BREW安装BFS Macports #端口安装BFS |
| BSD | |
freebsd #PKG安装BFS OpenBSD #PKG_ADD BFS |
bfs ,您可能需要安装一些依赖项。建造bfs的唯一绝对要求是C编译器,GNU MAKE和BASH。这些默认情况下是在许多系统上安装的,并且易于安装在大多数系统上。请参阅操作系统的构建软件文档。
bfs还取决于其某些功能的某些系统库。这是将它们安装在某些常见平台上的方法:
高山Linux
#apk添加acl {, - dev} attr libcap {, - dev} liburing-dev oniguruma-dev
Arch Linux
#Pacman -s Acl Attr libcap放弃oniguruma
Debian/Ubuntu
#APT安装ACL libacl1-dev attr libattr1-dev libcap2-bin libcap-dev libcap-dev liburing-dev libonig-dev
软呢帽
#DNF安装ACL libacl-Devel attr libcap-devel liburing-devel-oniguruma-devel
尼克斯
#NIX -ENV -I acl attr libcap放弃oniguruma
void linux
#xbps-install -s acl- {devel,progs} attr-progs libcap- {devel,progs} liburing-devel-devel oniguruma-devel
自制
$ BREW安装Oniguruma
Macports
#端口安装Oniguruma6
freebsd
#PKG安装Oniguruma
这些依赖性在技术上是可选的,尽管强烈建议使用。有关如何禁用它们的构建文档。
bfs 。下载版本之一或克隆git回购。然后运行
$ ./configure
$ make
这将构建./bin/bfs二进制。运行测试套件以确保其正常工作:
$ make check
如果您对速度感兴趣,则可能需要构建发布版本:
$ ./configure --enable-release
$ make
最后,如果您想在全球安装它,请运行
# make install