Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 ack 中,您可以使用 -Q 选项来转义搜索字符串中的所有字符,但如果您使用的搜索字符串看起来像 ack 的选项,这似乎不起作用。
我正在尝试在一组文件中搜索字符串“--branch”。所以我试试这个 ack 命令
ack -a -Q '--branch'
它响应Unknown option: branch。它将我的搜索字符串视为要解释的选项。有谁知道我可以使用哪些转义字符将 --branch 用作字符串?
Unknown option: branch
Ack 使用Getopt::Long 模块来处理命令行参数,因此它支持--选项来指示您希望选项处理在参数列表中的该点结束。
--
ack -a -- --branch
因此应该工作(它对我有用)。
也许使用 --match PATTERN 选项?
http://betterthangrep.com/