请列出所有文件路径,不要管 .gitignore 规则,也不要管是不是隐藏文件(因为用了 -uu),然后在结果中筛选出包含 BuiltInPrintService.apk 的行。
-u, --unrestricted
This flag reduces the level of "smart" filtering. Repeated uses (up to
3) reduces the filtering even more. When repeated three times, ripgrep
will search every file in a directory tree.
A single -u/--unrestricted flag is equivalent to --no-ignore. Two
-u/--unrestricted flags is equivalent to --no-ignore -./--hidden. Three
-u/--unrestricted flags is equivalent to --no-ignore -./--hidden
--binary.
The only filtering ripgrep still does when -uuu is given is to skip
symbolic links and to avoid printing matches from binary files.
Symbolic links can be followed via the -L/--follow flag, and binary
files can be treated as text files via the -a/--text flag.
这段英文文档非常详细地解释了 -u 及其叠加使用(-uu, -uuu)的具体含义。
简单来说,ripgrep (rg) 默认非常“聪明”,会自动帮你过滤掉很多不需要搜的文件(比如 .gitignore 里的文件、隐藏文件、二进制文件)。
-u (Unrestricted) 的作用就是让它“变笨”一点,减少过滤,搜更多的东西。
下面是这段文档的逐句详细翻译和拆解:
核心含义拆解
1. 总体概念
This flag reduces the level of "smart" filtering. Repeated uses (up to 3) reduces the filtering even more.
意思:这个标志降低了“智能”过滤的级别。重复使用它(最多 3 次)会进一步减少过滤。
2. 三个级别的具体定义(重点!)
文档明确列出了 -u 叠加三次的等价效果:
-u(输入一次)- 原文:
equivalent to --no-ignore - 意思:不再理会忽略规则。即使写在
.gitignore或.ignore里的文件,也会被搜索。 - 场景:你想搜
node_modules或构建目录里的代码。
- 原文:
-uu(输入两次)- 原文:
equivalent to --no-ignore -./--hidden - 意思:包含隐藏文件。除了忽略
.gitignore,还会搜索以.开头的文件(如.env,.config)。 - 场景:这就是你之前问的场景,你需要搜隐藏的配置或缓存文件。
- 原文:
-uuu(输入三次)- 原文:
equivalent to --no-ignore -./--hidden --binary - 意思:包含二进制文件。除了上面所有,还会尝试搜索图片、可执行程序等二进制文件。
- 场景:你想在
.jpg图片或编译好的程序里找字符串。
- 原文:
3. 最后的底线(即使是 -uuu 也不做的事)
The only filtering ripgrep still does when -uuu is given is to skip symbolic links and to avoid printing matches from binary files.
意思:即使你用了-uuu(火力全开模式),rg 仍然会保留最后两个底线:跳过符号链接 (Symbolic links):即快捷方式。如果不跳过,可能会导致死循环搜索。如果非要搜,请加-L(--follow)。不打印二进制文件的匹配内容:虽然它会搜二进制文件,但为了防止终端乱码,它只会告诉你“匹配到了某个二进制文件”,而不会把乱码打印出来。如果非要看乱码内容,请加-a(--text)。
总结
你之前使用的命令:
rg --files -uu | grep "BuiltInPrintService.apk" 结合这段文档,它的确切含义是:
“请列出所有文件路径,不要管 .gitignore 规则,也不要管是不是隐藏文件(因为用了 -uu),然后在结果中筛选出包含 BuiltInPrintService.apk 的行。”