xargs 不工作

发布于 2024-08-24 05:55:27 字数 125 浏览 3 评论 0原文

我想要所有带有assert_equal并且没有amazon的行。

我尝试跟随但它不起作用。

ack assert_equal | xargs ack -v amazon

I want all the lines with assert_equal and without amazon.

I tried following but it is not working.

ack assert_equal | xargs ack -v amazon

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

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

发布评论

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

评论(4

终弃我 2024-08-31 05:55:27

你不需要 xargs:

ack assert_equal | ack -v amazon

You don't need xargs:

ack assert_equal | ack -v amazon
呆橘 2024-08-31 05:55:27

您的命令似乎存在一些问题。在第一部分中:

确认断言_等于

您没有提供文件名,因此 ack 没有任何需要处理的内容。在第二部分中:

xargs ack -v 亚马逊

您正在使用 xargs 将初始 ack 的结果作为命令行参数提供给第二个 ack,即可能不是你想要的。 ack 已设计为接受标准输入数据,因此您根本不需要使用 xargs

这是一个应该更有效的声明:

确认断言_等于文件名| ack -v 亚马逊

或者,如果您从另一个命令获取输出,例如:

我的命令|确认断言_等于| ack -v 亚马逊

There seem to be a couple of problems with your command. In the first part:

ack assert_equal

you do not provide a filename, so ack has nothing to process. In the second part:

xargs ack -v amazon

you are using xargs to provide the results from the initial ack as command-line arguments to the second ack, which is probably not what you intended. ack is already designed to accept data on standard input, so you do not need to use xargs at all.

Here is a statement that should work better:

ack assert_equal filename | ack -v amazon

or, if you are getting the output from another command, something like:

my_command | ack assert_equal | ack -v amazon

眼眸里的那抹悲凉 2024-08-31 05:55:27

这段代码应该能让您了解您需要做什么。神奇之处在于 -print0 选项。不是直接的解决方案;我感觉很懒。

ack -f --print0 --php -G 'scripts' --invert-file-match|xargs -0 ls -l

this snippet should give you an idea as to what you need to do. The magic is in the -print0 option. Not a direct solution; i'm feeling lazy.

ack -f --print0 --php -G 'scripts' --invert-file-match|xargs -0 ls -l
丶视觉 2024-08-31 05:55:27

ack 不是 *nix 中的标准工具。既然你有了它,就可以了。但如果您使用的是没有它的 *nix 系统,请按照以下方法操作

awk '/assert_equal/&&!/amazon/' file

ack is not a standard tool in *nix. since you have it, its ok. But if you are on a *nix system which doesn't have it, here's how you can do it

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