Files
tldr/pages.zh/common/bfs.md

36 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# bfs
> 用于你的文件的广度优先搜索。
> 更多信息:<https://manned.org/bfs>。
- 通过扩展名查找文件:
`bfs {{root_path}} -name '{{*.ext}}'`
- 查找匹配多个路径/名称模式的文件:
`bfs {{root_path}} -path '{{**/path/**/*.ext}}' -or -name '{{*pattern*}}'`
- 查找匹配给定名称的目录,忽略大小写:
`bfs {{root_path}} -type d -iname '{{*lib*}}'`
- 查找匹配给定模式的文件,排除特定路径:
`bfs {{root_path}} -name '{{*.py}}' -not -path '{{*/site-packages/*}}'`
- 查找匹配给定大小范围的文件限制递归深度为“1”
`bfs {{root_path}} -maxdepth 1 -size {{+500k}} -size {{-10M}}`
- 对每个文件运行一个命令(在命令中使用 `{}` 以访问文件名):
`bfs {{root_path}} -name '{{*.ext}}' -exec {{wc -l}} {} \;`
- 查找今天修改的所有文件,并将结果作为参数传递给单个命令:
`bfs {{root_path}} -daystart -mtime {{-1}} -exec {{tar -cvf archive.tar}} {} \+`
- 查找空文件0字节或目录并详细删除它们
`bfs {{root_path}} -type {{f|d}} -empty -delete -print`