确认负前瞻给出错误

发布于 2024-12-19 11:35:52 字数 265 浏览 2 评论 0原文

我在使用 ack-grep 进行负面展望时遇到问题。

我正在运行这个命令:

ack-grep "paypal_responded(?!_at)"

但我收到错误:

bash: !_at: event not found

我尝试在各个地方添加反斜杠,但我也是使用 ack & 的新手。 linux,所以请将我视为新手并提供任何说明。

提前致谢。

I have a problem with using ack-grep with a negative look ahead.

I am running this command:

ack-grep "paypal_responded(?!_at)"

but I am getting the error:

bash: !_at: event not found

I have tried adding backslashes in various places, but I'm also new to using ack & linux, so please treat me as a newbie with any instructions.

Thanks in advance.

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

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

发布评论

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

评论(2

沦落红尘 2024-12-26 11:35:52

尝试 ack-grep 'paypal_responded(?!_at)'

您需要单引号以避免 bash 将 ! 解释为历史扩展命令。

Try ack-grep 'paypal_responded(?!_at)'

You need single-quote to avoid bash interpret ! as history expand command.

南街女流氓 2024-12-26 11:35:52

shell 将您输入中的 ! 解释为命令替换:

$ ack-grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
$ !ac
ack-grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
$ 

您需要告诉 shell ! 没有特殊含义;有两种方法可以做到这一点:

ack-grep "paypal_responded(?\!_at)"

ack-grep "paypal_responded\(?\!_at\)"

ack-grep 'paypal_responded(?!_at)'

单引号字符串应用的转换较少:

$ ack-grep "s\!" /etc/passwd
$ ack-grep 's!' /etc/passwd
$ 

The shell is interpreting the ! in your input as a command substitution:

$ ack-grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
$ !ac
ack-grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
$ 

You need to tell the shell that ! has no special meaning; there are two ways to do that:

ack-grep "paypal_responded(?\!_at)"

ack-grep "paypal_responded\(?\!_at\)"

or

ack-grep 'paypal_responded(?!_at)'

Single-quoted strings have fewer transformations applied to them:

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