我在使用ack-grep负面展望时遇到问题。
我正在运行这个命令:
ack-grep "paypal_responded(?!_at)"
但我收到错误:
bash: !_at: event not found
我尝试在各个地方添加反斜杠,但我对使用 ack 和 linux 也很陌生,所以请把我当作新手,有任何说明。
提前致谢。
我在使用ack-grep负面展望时遇到问题。
我正在运行这个命令:
ack-grep "paypal_responded(?!_at)"
但我收到错误:
bash: !_at: event not found
我尝试在各个地方添加反斜杠,但我对使用 ack 和 linux 也很陌生,所以请把我当作新手,有任何说明。
提前致谢。
尝试ack-grep 'paypal_responded(?!_at)'
您需要单引号以避免将 bash 解释!为历史扩展命令。
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
$