如何搜索'<'在 Windows 的 powershell 中使用 ack 的文件?

发布于 2024-11-26 22:39:26 字数 1017 浏览 0 评论 0 原文

我不知道如何逃避 '<'字符,我对“系统找不到指定的文件”错误感到困惑。有人可以帮忙吗?

我在 Windows XP 的 powershell 中使用 ack。

问题 ack-grep: chars escaping 与我的非常相似,但针对该问题提供和接受的解决方案对我不起作用。

PS C:\xampp\htdocs> ack abcd
<works as expected>
PS C:\xampp\htdocs> ack <
The redirection operator '<' is not supported yet.
At line:1 char:5
+ ack < <<<<
PS C:\xampp\htdocs> ack \<
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '\<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack [<]
The system cannot find the file specified.
PS C:\xampp\htdocs> ack '[<]'
The system cannot find the file specified.
PS C:\xampp\htdocs> ack '[\<]'
The system cannot find the file specified.
PS C:\xampp\htdocs> ack \Q<\E
The system cannot find the file specified.

I cannot figure out how to escape the '<' character, and I am confused by the 'The system cannot find the file specified' error. Can anyone help?

I am using ack in powershell in Windows XP.

The question ack-grep: chars escaping is very similar to mine, but the solutions offered and accepted for that question do not work for me.

PS C:\xampp\htdocs> ack abcd
<works as expected>
PS C:\xampp\htdocs> ack <
The redirection operator '<' is not supported yet.
At line:1 char:5
+ ack < <<<<
PS C:\xampp\htdocs> ack \<
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '\<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack [<]
The system cannot find the file specified.
PS C:\xampp\htdocs> ack '[<]'
The system cannot find the file specified.
PS C:\xampp\htdocs> ack '[\<]'
The system cannot find the file specified.
PS C:\xampp\htdocs> ack \Q<\E
The system cannot find the file specified.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

回梦 2024-12-03 22:39:26

您有什么理由不想使用 PowerShell 的正则表达式搜索吗?

Select-String '<' *.*

## or
dir -r | Select-String '<'

Is there any reason you don't want to use PowerShell's regex search?

Select-String '<' *.*

## or
dir -r | Select-String '<'
三生一梦 2024-12-03 22:39:26

PowerShell 中的转义字符是反引号:

PS C:\xampp\htdocs> ack `<

Escape character in PowerShell is backtick:

PS C:\xampp\htdocs> ack `<
清风不识月 2024-12-03 22:39:26

你的意思是awk吗?如果是这样,那么您所要做的就是: $awk '/

因为我没有安装 ack,所以我无法 100% 验证,但我会尝试一下这段代码:

ack  '<' --output '$1' -h

如果这不起作用,那么我建议阅读 man ackack --help 页面。

Do you mean awk? If so, then all you have to do is: $awk '/</ filename'

Since I don't have ack installed I can't verify 100%, but I would try this code out:

ack  '<' --output '$1' -h

If that doesn't work, then I would recommend reading through the man ack and the ack --help pages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文